update 基本完成当前检测数据

This commit is contained in:
g7hoo 2022-08-17 16:41:32 +08:00
parent 686002a48e
commit 3c4af47e2d

View File

@ -17,7 +17,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button v-if="$hasPermission('monitoring:qualityinspectionrecord:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button> <!-- <el-button v-if="$hasPermission('monitoring:qualityinspectionrecord:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button> -->
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -51,7 +51,7 @@
@operate-event="handleOperations" @operate-event="handleOperations"
@refreshDataList="getDataList" @refreshDataList="getDataList"
/> />
<fake-chart v-else :categories="echartCategories" :type-list="echartCheckTypes" /> <fake-chart v-else :categories="echartCategories" :type-list="echartCheckTypes" :series-data="echartsData" />
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
@ -90,6 +90,10 @@ const FakeChart = {
typeList: { typeList: {
type: Array, type: Array,
default: () => [] default: () => []
},
seriesData: {
type: Array,
default: () => []
} }
}, },
data() { data() {
@ -97,9 +101,17 @@ const FakeChart = {
chart: null, chart: null,
defaultOpts: { defaultOpts: {
title: { title: {
text: '统计数据' text: '检测类型统计数据'
}, },
tooltip: {}, tooltip: {},
legend: {
orient: 'vertical',
top: 10,
right: 20,
data: [
/** dynamic */
]
},
xAxis: { xAxis: {
data: [ data: [
/** dynamic */ /** dynamic */
@ -126,6 +138,22 @@ const FakeChart = {
}, },
immediate: true immediate: true
}, },
typeList: {
handler: function(val, oldVal) {
if (val && val !== oldVal) {
this.defaultOpts.legend.data.push(...val)
}
},
immediate: true
},
seriesData: {
handler: function(val, oldVal) {
if (val && val !== oldVal) {
this.defaultOpts.series.push(...val)
}
},
immediate: true
},
defaultOpts: { defaultOpts: {
handler: function(val) { handler: function(val) {
console.log('defaullt opts change: ', val) console.log('defaullt opts change: ', val)
@ -200,6 +228,8 @@ export default {
this.showGraph = value === dict[0] ? false : true this.showGraph = value === dict[0] ? false : true
}, },
getDataList() { getDataList() {
this.showGraph = false
this.dataType = '表格'
this.echartCategories = null this.echartCategories = null
this.echartCheckTypes.splice(0) this.echartCheckTypes.splice(0)
/** 设置默认日期 */ /** 设置默认日期 */
@ -227,7 +257,7 @@ export default {
this.dataListDynamic = this.parseDynamicData(res.data.data) || [] this.dataListDynamic = this.parseDynamicData(res.data.data) || []
console.log('dyname', this.dataListDynamic) this.buildGraphData()
}) })
}, },
@ -272,6 +302,34 @@ export default {
}) })
}, },
buildGraphData() {
/** 构造 echart 需要的数据 */
const result = []
this.echartCheckTypes.forEach(ect => {
result.push({ name: ect, type: 'bar', data: [] })
})
this.dataListDynamic.forEach((inspection, index) => {
console.log('inspection: ', inspection)
this.echartCategories.forEach(cate => {
if (cate in inspection) {
result[index].data.push(inspection[cate])
} else {
result[index].data.push('0')
}
})
})
this.echartsData = result
// [
// { name: '11', type: 'bar', data: [/**线1*/ 2, /**线2*/ 3] },
// { name: '222', type: 'bar', data: [1, 2, 3] }
// ]
console.log('echarts data: ', this.echartsData)
},
fetchList(type, startTime, endTime) { fetchList(type, startTime, endTime) {
switch (type) { switch (type) {
case 'sx': case 'sx':