Files
EdgeManager/src/views/scada/scadaQuery/index.vue

164 lines
4.1 KiB
Vue
Raw Normal View History

2022-07-10 03:36:18 +08:00
<template>
<d2-container>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="工序单元">
<el-select
v-model="formInline.workingSubclass"
filterable
clearable
placeholder="工序单元"
@change="getCodesByWorkingSubclass(formInline.workingSubclass)">
<el-option
v-for="workingSubclass in workingSubclasses"
:key="workingSubclass"
: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>
2022-07-10 03:36:18 +08:00
</el-form-item>
<el-form-item label="节点编码">
<el-select
v-model="formInline.code"
filterable
clearable
placeholder="节点编码">
<el-option
v-for="code in codes"
:key="code"
:value="code">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getData">查询</el-button>
</el-form-item>
</el-form>
<c-grid
:data="data">
<c-grid-column
field="id"
width="5%">
序号
</c-grid-column>
<c-grid-column
field="name"
width="16.25%">
节点名称
</c-grid-column>
<c-grid-column
field="value"
width="16.25%"
sort="true">
</c-grid-column>
<c-grid-column
field="device_code"
width="16.25%"
sort="true">
设备
</c-grid-column>
<c-grid-column
field="batch"
width="16.25%"
sort="true">
批次
</c-grid-column>
<c-grid-column
field="capture_time"
width="30%"
sort="true">
采集时间
</c-grid-column>
</c-grid>
</d2-container>
</template>
<script>
const now = new Date()
2022-07-10 03:36:18 +08:00
export default {
data () {
return {
formInline: {
workingSubclass: '',
time: [now - 3600 * 1000 * 24 * 7, +now],
2022-07-10 03:36:18 +08:00
code: ''
},
workingSubclasses: [],
codes: [],
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])
}
}]
}
2022-07-10 03:36:18 +08:00
}
},
methods: {
async getworkingSubclasses () {
try {
this.workingSubclasses = await this.$api.QUERY_WORKING_SUBCLASSES()
} catch (e) {
console.log(e)
}
},
async getCodesByWorkingSubclass (workingSubclass) {
try {
this.codes = await this.$api.QUERY_CODES(workingSubclass)
} catch (e) {
console.log(e)
}
},
async getData () {
try {
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
})
2022-07-10 03:36:18 +08:00
} catch (e) {
console.log(e)
}
}
},
mounted () {
this.getworkingSubclasses()
}
}
</script>