Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
c7313daa
Commit
c7313daa
authored
Apr 02, 2021
by
涂茜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add basic tools
parent
f847d9ce
Pipeline
#25460
passed with stages
in 4 minutes 13 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
313 additions
and
1 deletion
+313
-1
.umirc.js
.umirc.js
+1
-1
README.md
packages/BasicTools/README.md
+11
-0
package.json
packages/BasicTools/package.json
+29
-0
BasicTools.md
packages/BasicTools/src/BasicTools.md
+26
-0
Basic.tsx
packages/BasicTools/src/demos/Basic.tsx
+77
-0
index.js
packages/BasicTools/src/index.js
+139
-0
package.json
packages/DeviceTree/package.json
+4
-0
package.json
packages/Empty/package.json
+3
-0
package.json
packages/HistoryInfo/package.json
+8
-0
package.json
packages/ImageSelect/package.json
+4
-0
package.json
packages/QuotaSelect/package.json
+4
-0
package.json
packages/RealTimeInfo/package.json
+3
-0
package.json
packages/TimeRangePicker/package.json
+4
-0
No files found.
.umirc.js
View file @
c7313daa
...
...
@@ -71,7 +71,7 @@ export default {
},
{
title
:
'通用'
,
children
:
[
'ImageSelect'
,
'QuotaSelect'
,
'TimeRangePicker'
,
'MqttView'
],
children
:
[
'
BasicTools'
,
'
ImageSelect'
,
'QuotaSelect'
,
'TimeRangePicker'
,
'MqttView'
],
},
{
title
:
'数据录入'
,
...
...
packages/BasicTools/README.md
0 → 100644
View file @
c7313daa
# `@wisdom-components/BasicTools`
> TODO: description
## Usage
```
const basicTools = require('@wisdom-components/BasicTools');
// TODO: DEMONSTRATE API
```
packages/BasicTools/package.json
0 → 100644
View file @
c7313daa
{
"name"
:
"@wisdom-components/basictools"
,
"version"
:
"1.1.0"
,
"description"
:
"> TODO: description"
,
"author"
:
"tuqian <webtuqian@163.com>"
,
"homepage"
:
""
,
"license"
:
"ISC"
,
"main"
:
"lib/index.js"
,
"directories"
:
{
"lib"
:
"lib"
,
"test"
:
"__tests__"
},
"files"
:
[
"lib"
],
"publishConfig"
:
{
"registry"
:
"https://g.civnet.cn:4873/"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"https://g.civnet.cn:8443/ReactWeb5/wisdom-components.git"
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"moment"
:
"^2.27.0"
}
}
packages/BasicTools/src/BasicTools.md
0 → 100644
View file @
c7313daa
---
title
:
BasicTools - 通用工具库
nav
:
title
:
组件
path
:
/components
group
:
path
:
/
---
# BasicTools 通用工具库
## 代码演示
<code
src=
"./demos/Basic.tsx"
>
## 使用说明
```
javascript
import
{
getTimeRange
,
getRange
}
from
'@wisdom-components/BasicTools'
;
let
result1
=
getTimeRange
(
'lastYear'
);
let
result2
=
getTimeRange
(
'nextWeek'
);
let
result3
=
getRange
(
new
Date
(),
'day'
);
let
result4
=
getRange
(
''
,
'month'
);
```
packages/BasicTools/src/demos/Basic.tsx
0 → 100644
View file @
c7313daa
import
React
from
'react'
;
import
{
getTimeRange
,
getRange
}
from
'../index'
;
const
Demo
=
()
=>
{
return
(
<
div
>
<
h2
>
getTimeRange(type):
</
h2
>
<
div
>
<
b
>
全部:
</
b
>
{
JSON
.
stringify
(
getTimeRange
())
}
</
div
>
<
div
>
<
b
>
今年-thisYear:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'thisYear'
))
}
</
div
>
<
div
>
<
b
>
去年-lastYear:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'lastYear'
))
}
</
div
>
<
div
>
<
b
>
明年-nextYear:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'nextYear'
))
}
</
div
>
<
div
>
<
b
>
上季度-lastQuarter:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'lastQuarter'
))
}
</
div
>
<
div
>
<
b
>
本季度-thisQuarter:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'thisQuarter'
))
}
</
div
>
<
div
>
<
b
>
下季度-nextQuarter:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'nextQuarter'
))
}
</
div
>
<
div
>
<
b
>
上月-lastMonth:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'lastMonth'
))
}
</
div
>
<
div
>
<
b
>
本月-thisMonth:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'thisMonth'
))
}
</
div
>
<
div
>
<
b
>
下月-nextMonth:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'nextMonth'
))
}
</
div
>
<
div
>
<
b
>
上周-lastWeek:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'lastWeek'
))
}
</
div
>
<
div
>
<
b
>
本周-thisWeek:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'thisWeek'
))
}
</
div
>
<
div
>
<
b
>
下周-nextWeek:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'nextWeek'
))
}
</
div
>
<
div
>
<
b
>
昨天-lastDay:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'lastDay'
))
}
</
div
>
<
div
>
<
b
>
今天-thisDay:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'thisDay'
))
}
</
div
>
<
div
>
<
b
>
明天-nextDay:
</
b
>
{
JSON
.
stringify
(
getTimeRange
(
'nextDay'
))
}
</
div
>
<
br
/>
<
h2
>
getRange(date, type):
</
h2
>
<
div
>
<
b
>
type:
</
b
>
{
JSON
.
stringify
(
getRange
())
}
</
div
>
<
div
>
<
b
>
type-day:
</
b
>
{
JSON
.
stringify
(
getRange
(
new
Date
(),
'day'
))
}
</
div
>
<
div
>
<
b
>
type-week:
</
b
>
{
JSON
.
stringify
(
getRange
(
new
Date
(),
'week'
))
}
</
div
>
<
div
>
<
b
>
type-month:
</
b
>
{
JSON
.
stringify
(
getRange
(
new
Date
(),
'month'
))
}
</
div
>
<
div
>
<
b
>
type-year:
</
b
>
{
JSON
.
stringify
(
getRange
(
new
Date
(),
'year'
))
}
</
div
>
</
div
>
);
};
export
default
Demo
;
packages/BasicTools/src/index.js
0 → 100644
View file @
c7313daa
import
moment
from
'moment'
;
// 根据设定查询条件 返回时间范围
const
getTimeRange
=
(
type
)
=>
{
let
start
=
''
,
end
=
''
;
switch
(
type
)
{
case
'thisYear'
:
// 今年
start
=
moment
().
startOf
(
'year'
);
end
=
moment
().
endOf
(
'year'
);
break
;
case
'lastYear'
:
// 去年
start
=
moment
()
.
year
(
moment
().
year
()
-
1
)
.
startOf
(
'year'
);
end
=
moment
()
.
year
(
moment
().
year
()
-
1
)
.
endOf
(
'year'
);
break
;
case
'nextYear'
:
// 明年
start
=
moment
()
.
year
(
moment
().
year
()
+
1
)
.
startOf
(
'year'
);
end
=
moment
()
.
year
(
moment
().
year
()
+
1
)
.
endOf
(
'year'
);
break
;
case
'lastQuarter'
:
// 上季度
start
=
moment
()
.
quarter
(
moment
().
quarter
()
-
1
)
.
startOf
(
'quarter'
);
end
=
moment
()
.
quarter
(
moment
().
quarter
()
-
1
)
.
endOf
(
'quarter'
);
break
;
case
'thisQuarter'
:
// 本季度
start
=
moment
().
startOf
(
'quarter'
);
end
=
moment
().
endOf
(
'quarter'
);
break
;
case
'nextQuarter'
:
// 下季度
start
=
moment
()
.
quarter
(
moment
().
quarter
()
+
1
)
.
startOf
(
'quarter'
);
end
=
moment
()
.
quarter
(
moment
().
quarter
()
+
1
)
.
endOf
(
'quarter'
);
break
;
case
'lastMonth'
:
// 上月
start
=
moment
()
.
month
(
moment
().
month
()
-
1
)
.
startOf
(
'month'
);
end
=
moment
()
.
month
(
moment
().
month
()
-
1
)
.
endOf
(
'month'
);
break
;
case
'thisMonth'
:
// 本月
start
=
moment
().
startOf
(
'month'
);
end
=
moment
().
endOf
(
'month'
);
break
;
case
'nextMonth'
:
// 下月
start
=
moment
()
.
month
(
moment
().
month
()
+
1
)
.
startOf
(
'month'
);
end
=
moment
()
.
month
(
moment
().
month
()
+
1
)
.
endOf
(
'month'
);
break
;
case
'lastWeek'
:
// 上周
start
=
moment
().
subtract
(
14
,
'days'
);
end
=
moment
().
subtract
(
7
,
'days'
);
break
;
case
'thisWeek'
:
// 本周
start
=
moment
().
subtract
(
6
,
'days'
);
end
=
moment
();
break
;
case
'nextWeek'
:
// 下周
start
=
moment
().
subtract
(
-
1
,
'days'
);
end
=
moment
().
subtract
(
-
7
,
'days'
);
break
;
case
'lastDay'
:
// 昨天
start
=
moment
().
subtract
(
1
,
'days'
);
end
=
moment
().
subtract
(
1
,
'days'
);
break
;
case
'thisDay'
:
// 今天
start
=
moment
();
end
=
moment
();
break
;
case
'nextDay'
:
// 明天
start
=
moment
().
subtract
(
-
1
,
'days'
);
end
=
moment
().
subtract
(
-
1
,
'days'
);
break
;
default
:
start
=
moment
();
end
=
moment
();
break
;
}
if
(
!!
start
&&
!!
end
)
{
start
=
start
.
format
(
startFormat
);
end
=
end
.
format
(
endFormat
);
}
return
{
startTime
:
start
,
endTime
:
end
};
};
const
getRange
=
(
date
,
type
)
=>
{
let
start
=
''
,
end
=
''
;
switch
(
type
)
{
case
'day'
:
start
=
moment
(
date
);
end
=
moment
(
date
);
break
;
case
'week'
:
start
=
moment
(
date
).
startOf
(
'week'
);
end
=
moment
(
date
).
endOf
(
'week'
);
break
;
case
'month'
:
start
=
moment
(
date
).
startOf
(
'month'
);
end
=
moment
(
date
).
endOf
(
'month'
);
break
;
case
'year'
:
start
=
moment
(
date
).
startOf
(
'year'
);
end
=
moment
(
date
).
endOf
(
'year'
);
break
;
default
:
start
=
moment
(
date
);
end
=
moment
(
date
);
break
;
}
if
(
!!
start
&&
!!
end
)
{
start
=
start
.
format
(
startFormat
);
end
=
end
.
format
(
endFormat
);
}
return
{
startTime
:
start
,
endTime
:
end
};
};
export
{
getTimeRange
,
getRange
};
const
startFormat
=
'YYYY-MM-DD 00:00:00'
;
const
endFormat
=
'YYYY-MM-DD 23:59:59'
;
packages/DeviceTree/package.json
View file @
c7313daa
...
...
@@ -22,5 +22,9 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"classnames"
:
"^2.2.6"
,
"@wisdom-components/Empty"
:
"^1.2.0"
}
}
packages/Empty/package.json
View file @
c7313daa
...
...
@@ -23,5 +23,8 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"classnames"
:
"^2.2.6"
}
}
packages/HistoryInfo/package.json
View file @
c7313daa
...
...
@@ -22,5 +22,13 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"moment"
:
"^2.27.0"
,
"classnames"
:
"^2.2.6"
,
"@wisdom-components/Empty"
:
"^1.2.0"
,
"@wisdom-components/timerangepicker"
:
"^1.2.0"
,
"highcharts"
:
"^9.0.1"
,
"highcharts-react-official"
:
"^3.0.0"
}
}
packages/ImageSelect/package.json
View file @
c7313daa
...
...
@@ -22,5 +22,9 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"classnames"
:
"^2.2.6"
,
"@wisdom-components/Empty"
:
"^1.2.0"
}
}
packages/QuotaSelect/package.json
View file @
c7313daa
...
...
@@ -22,5 +22,9 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"classnames"
:
"^2.2.6"
,
"@wisdom-components/Empty"
:
"^1.2.0"
}
}
packages/RealTimeInfo/package.json
View file @
c7313daa
...
...
@@ -22,5 +22,8 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"classnames"
:
"^2.2.6"
}
}
packages/TimeRangePicker/package.json
View file @
c7313daa
...
...
@@ -22,5 +22,9 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"classnames"
:
"^2.2.6"
,
"@wisdom-components/Empty"
:
"^1.2.0"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment