1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
| <template>
| <BaseCard size="middle-s" direction="down">
| <template #content>
| <el-form :inline="true">
| <OptionMission v-model="mission" @init-over="initOver"></OptionMission>
| <OptionType
| v-model="formSearch.deviceType"
| @init-over="initOver"
| ></OptionType>
| <OptionDevice
| :type="formSearch.deviceType"
| v-model="formSearch.deviceCode"
| @init-over="initOver"
| ></OptionDevice>
| <OptionTime
| v-model="formSearch.timeArray"
| :start-date="dateRange[0]"
| :end-date="dateRange[1]"
| ></OptionTime>
| <el-button
| :loading="loading"
| type="primary"
| class="el-button-custom"
| @click="handleClick"
| >
| 分析
| </el-button>
| </el-form>
| </template>
| </BaseCard>
| </template>
|
| <script>
| // 可能会有延时初始化的选项总数,包括走航任务、设备类型、设备编号
| const MAX_INIT = 3;
| // 已初始化的选项数
| let initCount = 0;
| let initEvents = [];
|
| // 搜索框
| export default {
| props: {
| loading: Boolean,
| searchTime: Array
| },
| data() {
| return {
| mission: undefined,
| formSearch: {
| deviceType: '',
| deviceCode: '',
| timeArray: []
| },
| // 可选日期范围,根据走航任务决定
| dateRange: []
| };
| },
| emits: ['search'],
| watch: {
| searchTime(nV, oV) {
| if (nV != oV) {
| this.formSearch.timeArray = this.searchTime;
| }
| },
| mission(nV, oV) {
| if (nV != oV) {
| this.onInit(() => {
| this.formSearch.timeArray = [
| new Date(nV.startTime),
| new Date(nV.endTime)
| ];
| this.dateRange = [new Date(nV.startTime), new Date(nV.endTime)];
| this.formSearch.deviceType = nV.deviceType;
| this.formSearch.deviceCode = nV.deviceCode;
|
| // 代表首次进入界面,此时自动执行首个任务的数据查询操作
| if (oV == undefined) {
| setTimeout(() => {
| this.handleClick();
| }, 500);
| }
| });
| }
| }
| },
| methods: {
| // 各选项初始化加载完成判定
| initOver() {
| initCount++;
| if (initCount == MAX_INIT && initEvents.length > 0) {
| initEvents.forEach((e) => {
| e();
| });
| initEvents = [];
| }
| },
| onInit(event) {
| if (initCount == MAX_INIT) {
| event();
| } else {
| initEvents.push(event);
| }
| },
| handleClick() {
| this.$emit('search', { ...this.formSearch, mission: this.mission });
| }
| }
| };
| </script>
| <style scoped lang="scss">
| .map-date-selector {
| display: inline-block;
| position: relative;
| /* left: 0;
| right: 0;
| top: 0px; */
| /* padding: 0 4px; */
| /* color: ffffffbd; */
| /* background-color: antiquewhite; */
| }
|
| .p-events-auto {
| }
|
| .el-form-item {
| margin-bottom: 0px;
| margin-right: 8px !important;
| }
| </style>
|
|