-
-
+
+
+
+
+ 月
+ 年
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/statistic-analysis/state/page-two-time/page-two-time.component.scss b/src/app/statistic-analysis/state/page-two-time/page-two-time.component.scss
index 5984003..5bbff55 100644
--- a/src/app/statistic-analysis/state/page-two-time/page-two-time.component.scss
+++ b/src/app/statistic-analysis/state/page-two-time/page-two-time.component.scss
@@ -17,35 +17,34 @@
}
}
+//头部搜索栏
.header {
- padding: 10px;
- box-sizing: border-box;
border-bottom: 1px solid #999;
- min-height: 70px;
- .queryBox {
- box-sizing: border-box;
- padding: 5px 15px;
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- align-items:center;
- justify-content:center;
- .queryField {
- margin: 0 15px;
- font-size: 14px;
- input {
- width: 180px;
- height: 22px;
- line-height: 22px;
- }
- }
- .btnbox{
- float: right;
+ height: 70px;
+ box-sizing: border-box;
+ padding: 0 15px;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ align-items:center;
+ justify-content:center;
+ .queryField {
+ margin: 0 10px;
+ font-size: 14px;
+ .mat-form-field {
+ width: 130px;
+ max-height: 50px;;
+ margin: 0 15px 0 10px;
}
-
- } //queryBox
+ }
+ .fixedCss{
+ position: fixed;
+ top: 78px;
+ right: 32px;
+ }
}
+//echarts div公有样式
.publicCss{
height: 350px;
width: 50%;
diff --git a/src/app/statistic-analysis/state/page-two-time/page-two-time.component.ts b/src/app/statistic-analysis/state/page-two-time/page-two-time.component.ts
index b26dd39..618c624 100644
--- a/src/app/statistic-analysis/state/page-two-time/page-two-time.component.ts
+++ b/src/app/statistic-analysis/state/page-two-time/page-two-time.component.ts
@@ -20,18 +20,11 @@ export class PageTwoTimeComponent implements OnInit {
@ViewChild('pageTwoName')pageTwoName :PageTwoNameComponent; //父组件中获得子组件的引用
ngOnInit(): void {
- this.startTime = new FormControl( (new Date()).getFullYear()-10 )
- this.endTime = new FormControl( (new Date()).getFullYear() )
- this.adapter.setLocale('CH')
+ this.dateInit()
}
isQuery:boolean = true; //横纵向查询
- //查询
- query () {
-
- }
-
//shao
toggleTrue () {
this.isQuery = true
@@ -44,54 +37,58 @@ export class PageTwoTimeComponent implements OnInit {
this.echartsData.statefulInspectionToggle = true
}
- startTime:any; //查询开始时间
- endTime:any; //查询结束时间
-
- //选择开始时间
- startEvent (e: MatDatepickerInputEvent) {
- let nowTime = new Date()
- if (nowTime < e.value) {
+ selectType:string = 'month'; //选择当前的 查询类型 按月/年
+
+ //查询数据
+ years:any = []
+ selectMonth:any = [1,2,3,4,5,6,7,8,9,10,11,12]
+
+ //日期初始化
+ dateInit () {
+ let date = (new Date()).getFullYear()
+ for (let i=date; i>=date-10;i--) {
+ this.years.unshift(i)
+ }
+ }
+
+ selectOneYear:any = (new Date()).getFullYear() //开始年份
+ selectTwoYear:any = (new Date()).getFullYear() //结束年份
+ selectStartMonth:any = 1 //开始月份
+ selectEndMonth:any = (new Date()).getMonth()+1 //结束月份
+ //按月查询
+ monthSubmit (e) {
+ if (e.selectTwoYear >= e.selectOneYear) {
+ let startTime = e.selectOneYear + '-' + e.selectStartMonth + '-' + 1 + ' ' + 0 + ':' + 0 +':'+ 0
+ let endTime = e.selectTwoYear + '-' + e.selectEndMonth + '-' + 31 + ' ' + 23 + ':' + 59 +':'+ 59
+ console.log(startTime)
+ console.log(endTime)
+ } else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
- this.snackBar.open('选择时间不能大于现在时间段','确定',config);
- this.startTime = new FormControl( new Date(new Date().toLocaleDateString()) )
- } else {
- this.startTime = new FormControl(e.value)
+ this.snackBar.open('请选择正确时间区段','确定',config);
}
}
- //选择结束时间
- endEvent (e: MatDatepickerInputEvent) {
- let oneDay:number = 86399000; //一天的毫秒数
- let selectDay = (e.value).toLocaleDateString() //选择的年月日
- let newDay = (new Date()).toLocaleDateString() //现在的年月日
- let nowTime = new Date() //现在的时间
- if (nowTime < e.value && selectDay!=newDay) { //选择时间段大于现在时间段时
+
+ selectStartYear:any = (new Date()).getFullYear() //开始年份
+ selectEndYear:any = (new Date()).getFullYear() //结束年份
+ //按年查询
+ yearSubmit (e) {
+ if (e.selectEndYear >= e.selectStartYear) {
+ let startTime = e.selectStartYear + '-' + 1 + '-' + 1 + ' ' + 0 + ':' + 0 +':'+ 0
+ let endTime = e.selectEndYear + '-' + 12 + '-' + 31 + ' ' + 23 + ':' + 59 +':'+ 59
+ console.log(startTime)
+ console.log(endTime)
+ } else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
- this.snackBar.open('选择时间不能大于现在时间段','确定',config);
- this.endTime = new FormControl( new Date() )
- } else if (nowTime > e.value && selectDay!=newDay) { //正常情况下 时间+1天
- this.endTime = new FormControl( new Date(e.value.getTime()+oneDay) )
- } else if ( selectDay == newDay ) { //选择时间段是今天时
- this.endTime = new FormControl( new Date() )
+ this.snackBar.open('请选择正确时间区段','确定',config);
}
}
- //处理时间 传入 new Date()格式
- getTime(date){
- let year = date.getFullYear(); //年
- let month = date.getMonth() + 1; //月
- let day = date.getDate(); //日
- let hour = date.getHours() //时
- let min = date.getMinutes(); //分
- let seconds = date.getSeconds(); //秒
- return year+'-'+month+'-'+ day + " "+ hour +':'+ min +':'+ seconds;
- }
-
}