Commit fd4f831e authored by wends's avatar wends

update mock data

parent 9025fa9b
...@@ -66,13 +66,13 @@ ...@@ -66,13 +66,13 @@
</el-form> </el-form>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col <el-col
v-for="(chart, index) in chartList" v-for="(chart) in chartList"
:key="100 + index" :key="chart.id"
:span="12" :span="12"
style="height: 400px" style="height: 400px"
> >
<g2-line <g2-line
:id="'line-' + index" :id="'line-' + chart.propertyCode"
:title="chart.propertyName" :title="chart.propertyName"
:line-data="setChartData(chart.propertyCode)" :line-data="setChartData(chart.propertyCode)"
:description="chart.propertyUnit" :description="chart.propertyUnit"
...@@ -118,7 +118,79 @@ export default { ...@@ -118,7 +118,79 @@ export default {
yFields: [ yFields: [
{ type: 'array', required: true, message: '请至少选择一个属性', trigger: 'change' } { type: 'array', required: true, message: '请至少选择一个属性', trigger: 'change' }
] ]
},
fakeData: [
{
time: null,
value: {
inpressure: 110,
outpressure: 21
}
},
{
time: null,
value: {
inpressure: 111,
outpressure: 25
}
},
{
time: null,
value: {
inpressure: 112,
outpressure: 24
}
},
{
time: null,
value: {
inpressure: 115,
outpressure: 23
}
},
{
time: null,
value: {
inpressure: 117,
outpressure: 22
}
},
{
time: null,
value: {
inpressure: 110,
outpressure: 21
}
},
{
time: null,
value: {
inpressure: 111,
outpressure: 25
}
},
{
time: null,
value: {
inpressure: 112,
outpressure: 24
} }
},
{
time: null,
value: {
inpressure: 115,
outpressure: 23
}
},
{
time: null,
value: {
inpressure: 117,
outpressure: 22
}
}
]
} }
}, },
created() { created() {
...@@ -143,6 +215,8 @@ export default { ...@@ -143,6 +215,8 @@ export default {
refresh: 1 refresh: 1
} }
this.getDetail(parseInt(this.activeModel)) this.getDetail(parseInt(this.activeModel))
this.chartList = []
clearInterval(this.timer)
}, },
getDetail(id) { getDetail(id) {
Promise.all([getModelInstanceList({ id }), getModelDetail({ id })]) Promise.all([getModelInstanceList({ id }), getModelDetail({ id })])
...@@ -168,13 +242,17 @@ export default { ...@@ -168,13 +242,17 @@ export default {
const form = `form${this.activeModel}` const form = `form${this.activeModel}`
this.$refs[form][0].validate() this.$refs[form][0].validate()
.then(_ => { .then(_ => {
this.chartList = this.chartField.yFields.map(v => {
const prop = this.propertyList.find(item => item.id === v)
return {
...prop
}
})
this.chartData = [] this.chartData = []
this.chartList = []
this.mockData()
.then(_ => {
const arr = []
this.propertyList.forEach(v => {
const index = this.chartField.yFields.findIndex(item => item === v.id)
index !== -1 && arr.push({ ...v })
})
this.chartList = [...arr]
})
this.timer && clearInterval(this.timer) this.timer && clearInterval(this.timer)
this.timer = setInterval(async() => { this.timer = setInterval(async() => {
await this.mockData() await this.mockData()
...@@ -185,14 +263,25 @@ export default { ...@@ -185,14 +263,25 @@ export default {
}, },
mockData() { mockData() {
return new Promise(resolve => { return new Promise(resolve => {
// this.chartData.pop() this.fakeData.shift()
this.chartData.push({ this.fakeData.push({
time: new Date().getTime(), time: null,
value: { value: {
inpressure: this.random(100, 120), inpressure: this.random(80, 120),
outpressure: this.random(20, 30) outpressure: this.random(20, 30)
} }
}) })
const arr = []
const time = new Date().getTime()
for (let i = 0; i < 10; i++) {
arr.push({
time: time - (9 - i) * 1000,
value: {
...this.fakeData[i].value
}
})
}
this.chartData = [...arr]
resolve() resolve()
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment