完成自动类型检查和查询功能

This commit is contained in:
Yu Sun
2022-07-12 22:36:14 +08:00
parent 5fdfc04349
commit 68f86c94b7
4 changed files with 113 additions and 31 deletions

View File

@@ -26,7 +26,19 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
return request({ url: '?query=codes&working_subclass=' + workingSubclass })
},
QUERY_NODE_DATA (workingSubclass, code) {
return request({ url: '?query=node_data&working_subclass=' + workingSubclass + '&code=' + code })
QUERY_NODE_DATA ({
workingSubclass,
startTime,
endTime,
code
} = {}) {
let url = '?query=node_data&working_subclass=' + workingSubclass + '&start_time=' + startTime + '&end_time=' + endTime
if (code) {
url += `&code=${code}`
}
return request({
url: url,
timeout: 20000
})
}
})

View File

@@ -14,6 +14,19 @@
:value="workingSubclass">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="采集时间">
<el-date-picker
v-model="formInline.time"
type="datetimerange"
:clearable="false"
:picker-options="pickerOptions"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="timestamp"
align="right">
</el-date-picker>
</el-form-item>
<el-form-item label="节点编码">
<el-select
@@ -73,16 +86,46 @@
</template>
<script>
const now = new Date()
export default {
data () {
return {
formInline: {
workingSubclass: '',
time: [now - 3600 * 1000 * 24 * 7, +now],
code: ''
},
workingSubclasses: [],
codes: [],
data: []
data: [],
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])
}
}]
}
}
},
methods: {
@@ -102,7 +145,12 @@ export default {
},
async getData () {
try {
this.data = await this.$api.QUERY_NODE_DATA(this.formInline.workingSubclass, this.formInline.code)
this.data = await this.$api.QUERY_NODE_DATA({
workingSubclass: this.formInline.workingSubclass,
startTime: this.formInline.time[0],
endTime: this.formInline.time[1],
code: this.formInline.code
})
} catch (e) {
console.log(e)
}