zhanghua
2023-11-10 a1fb7d5473505c08cd0a20f68d3007c6efd383ff
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<template>
  <div class="header">
    <el-form :inline="true" :model="seachData" class="demo-form-inline">
      <el-form-item label="">
        <el-select
          style="width: 140px"
          v-model="seachData.ownerIndex"
          placeholder="所属单位"
        >
          <el-option
            v-for="(item, index) in ownerOptions"
            :key="item.Id"
            :label="item.Name"
            :value="index"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-select
          style="width: 120px"
          v-model="seachData.status"
          placeholder="排放状态"
        >
          <el-option
            v-for="item in statusOptions"
            :key="item.label"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-select
          style="width: 120px"
          v-model="seachData.onlineStatus"
          placeholder="整体状态"
        >
          <el-option
            v-for="item in onlineStatusOptions"
            :key="item.label"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
 
      <el-form-item>
        <el-radio v-model="seachData.type" label="1">监控设备</el-radio>
        <el-radio v-model="seachData.type" label="2">监测设备</el-radio>
      </el-form-item>
      <el-form-item label="">
        <el-date-picker
          v-model="seachData.alarmTime"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getList">刷新</el-button>
        <el-button type="primary" @click="resetAll">重置</el-button>
 
        <el-button type="primary" @click="exportTableData">导出</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
import realTimeApi from "@/api/smoke/realTime";
 
export default {
  data() {
    return {
      onlineStatusOptions: [
        {
          label: "正常",
          value: 1,
        },
        {
          label: "离线",
          value: 2,
        },
        {
          label: "异常离线",
          value: 3,
        },
      ],
      statusOptions: [
        {
          label: "正常",
          value: "NORMAL",
        },
        {
          label: "预警",
          value: "ALARM",
        },
        {
          label: "超标",
          value: "EXCESS",
        },
        {
          label: "离线",
          value: "DOWN",
        },
        {
          label: "异常离线",
          value: "OFF",
        },
      ],
      ownerOptions: [],
      seachData: {},
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  created() {},
  mounted() {
    this.getOwnerOptions();
  },
  methods: {
    // 获取所属单位
    getOwnerOptions() {
      const param = { pageSize: 100, pageNum: 1 };
      realTimeApi
        .findCustomerList(param)
        .then((res) => {
          this.ownerOptions = res.list;
        })
        .catch((err) => this.$message.error(err));
    },
 
    resetAll() {
      this.seachData = {};
      this.$emit("getList", { seachData: this.seachData });
    },
    getList() {
      if (this.seachData.ownerIndex !== undefined) {
        const ownerItem = this.ownerOptions[this.seachData.ownerIndex];
        this.seachData.owner = ownerItem.Pid + ownerItem.Id + "/";
      }
      this.$emit("getList", { seachData: this.seachData });
    },
    exportTableData() {
      if (this.seachData.ownerIndex !== undefined) {
        const ownerItem = this.ownerOptions[this.seachData.ownerIndex];
        this.seachData.owner = ownerItem.Pid + ownerItem.Id + "/";
      }
      this.$emit("exportTable", { seachData: this.seachData });
    },
  },
};
</script>
 
<style lang="scss" scoped>
.header {
  line-height: normal;
  margin-left: 20px;
}
</style>