This commit is contained in:
2023-05-22 14:21:16 +08:00
parent 61d55ac797
commit 997c8c86eb
40 changed files with 247 additions and 186 deletions

View File

@@ -18,22 +18,60 @@ import resize from '@/utils/chartMixins/resize'
export default {
name: 'DefectScatterPlotChart',
mixins: [resize],
props: {
defectMsg: {
type: Object,
default: () => {
return {}
}
}
},
data() {
return {
chartDom: '',
chart: '',
chartHeight: tableHeight(446)
chartHeight: tableHeight(446),
list: [
{ label: 'S', value: 's' },
{ label: 'M', value: 'm' },
{ label: 'L', value: 'l' },
{ label: 'XL', value: 'xl' },
{ label: '气泡', value: 'bl' },
{ label: '变形', value: 'distortion' },
{ label: '纤维', value: 'fiber' },
{ label: '划伤', value: 'scratch' },
{ label: '结节', value: 'knot' },
{ label: '结石', value: 'stone' },
{ label: '铂金', value: 'pt' },
{ label: '拖尾', value: 'tail' },
{ label: 'ADG', value: 'adg' },
{ label: '点状缺陷', value: 'tin' },
{ label: '锡缺陷(顶部)', value: 'top' },
{ label: '锡缺陷(底部)', value: 'bottom' },
{ label: '无法识别', value: 'iisrest' }
]
}
},
mounted() {
window.addEventListener('resize', () => {
this.chartHeight = tableHeight(446)
})
setTimeout(() => {
},
watch: {
defectMsg: function () {
this.getChart()
}, 20)
}
},
methods: {
transLabel(v) {
let label = ''
for (let l = 0; l < this.list.length; l++) {
if (v === this.list[l].value) {
label = this.list[l].label
}
}
return label
},
getChart() {
if (
this.chart !== null &&
@@ -44,105 +82,28 @@ export default {
}
this.chartDom = document.getElementById('defectScatterPlotChart')
this.chart = echarts.init(this.chartDom)
const dataS = [
[1, 55],
[2, 25],
[3, 56],
[4, 33],
[5, 42],
[6, 82],
[7, 74],
[8, 78],
[9, 267],
[10, 185],
[11, 39],
[12, 41],
[13, 64],
[14, 108],
[15, 108],
[16, 33],
[17, 94],
[18, 186],
[19, 57],
[20, 22],
[21, 39],
[22, 94],
[23, 99],
[24, 31],
[25, 42],
[26, 154],
[27, 234],
[28, 160],
[29, 134],
[30, 52],
[31, 46]
]
const dataM = [
[1, 26],
[2, 85],
[3, 78],
[4, 21],
[5, 41],
[6, 56],
[7, 64],
[8, 55],
[9, 76],
[10, 91],
[11, 84],
[12, 64],
[13, 70],
[14, 77],
[15, 109],
[16, 73],
[17, 54],
[18, 51],
[19, 91],
[20, 73],
[21, 73],
[22, 84],
[23, 93],
[24, 99],
[25, 146],
[26, 113],
[27, 81],
[28, 56],
[29, 82],
[30, 106],
[31, 118]
]
const dataL = [
[1, 91],
[2, 65],
[3, 83],
[4, 109],
[5, 106],
[6, 109],
[7, 106],
[8, 89],
[9, 53],
[10, 80],
[11, 117],
[12, 99],
[13, 95],
[14, 116],
[15, 108],
[16, 134],
[17, 79],
[18, 71],
[19, 97],
[20, 84],
[21, 87],
[22, 104],
[23, 87],
[24, 168],
[25, 65],
[26, 39],
[27, 39],
[28, 93],
[29, 188],
[30, 174],
[31, 187]
]
console.log(this.defectMsg)
let legendList = []
let seriesList = []
for (let i in this.defectMsg) {
console.log(i)
console.log(this.transLabel(i))
legendList.push(this.transLabel(i))
let arr1 = []
let obj = {}
for (let j of this.defectMsg[i]) {
let arr2 = []
arr2.push(parseInt(j.xpos))
arr2.push(parseInt(j.ypos))
arr1.push(arr2)
}
obj.name = this.transLabel(i)
obj.type = 'scatter'
obj.data = arr1
obj.symbolSize = 5
seriesList.push(obj)
}
console.log(seriesList)
var option = {
color: [
'#5d7ab7',
@@ -166,7 +127,7 @@ export default {
legend: {
top: 10,
left: 0,
data: ['S', 'M', 'L'],
data: legendList,
textStyle: {
fontSize: 9
},
@@ -185,7 +146,6 @@ export default {
nameTextStyle: {
fontSize: 16
},
max: 31,
splitLine: {
show: true,
lineStyle: {
@@ -207,26 +167,27 @@ export default {
}
}
},
series: [
{
name: 'S',
type: 'scatter',
data: dataS,
symbolSize: 5
},
{
name: 'M',
type: 'scatter',
data: dataM,
symbolSize: 5
},
{
name: 'L',
type: 'scatter',
data: dataL,
symbolSize: 5
}
]
series: seriesList
// series: [
// {
// name: 'S',
// type: 'scatter',
// data: dataS,
// symbolSize: 5
// },
// {
// name: 'M',
// type: 'scatter',
// data: dataM,
// symbolSize: 5
// },
// {
// name: 'L',
// type: 'scatter',
// data: dataL,
// symbolSize: 5
// }
// ]
}
option && this.chart.setOption(option)
}

View File

@@ -107,6 +107,10 @@ const tablePropsP = [
{
prop: 'currentValue',
label: '当前值'
},
{
prop: 'time',
label: '参数记录时间'
}
]
const tablePropsD = [

View File

@@ -29,7 +29,6 @@
v-model="form.detectTime"
type="datetime"
placeholder="选择抽检时间"
value-format="yyyy-MM-DDTHH:mm:ss"
style="width: 100%"
>
</el-date-picker>
@@ -168,8 +167,7 @@ export default {
this.tableH = tableHeight(250)
})
this.form.model = 'G8.5'
// this.form.detectTime = moment().format('yyyy-MM-DD HH:mm:ss')
this.form.detectTime = moment().format('yyyy-MM-DD HH:mm:ss')
this.form.detectTime = new Date()
},
selectItem() {
this.getStandard()

View File

@@ -37,7 +37,9 @@
@click="drawPic"
>绘图</el-button
>
<el-button type="primary" size="small" plain>导出</el-button>
<el-button type="primary" size="small" plain @click="exportExl"
>导出</el-button
>
</div>
<div class="line2">
<el-checkbox-group v-model="checkList">
@@ -52,7 +54,10 @@
<div>
<span class="title">缺陷散点图(1245241242)</span>
</div>
<defect-scatter-plot-chart ref="poltChart" />
<defect-scatter-plot-chart
ref="poltChart"
:defectMsg="defectList"
/>
<div class="bottom">
<div style="margin-bottom: 10px">
<span class="title">合计</span>
@@ -69,7 +74,13 @@
import { tableHeight } from '@/utils/index'
import defectScatterPlotTotal from './../components/defectScatterPlotTotal.vue'
import defectScatterPlotChart from './../components/defectScatterPlotChart.vue'
import { queryPoint, drawPoint, queryPointClear } from '@/api/qualityManagement'
import {
queryPoint,
drawPoint,
queryPointClear,
pointExport,
pointExport2
} from '@/api/qualityManagement'
import moment from 'moment'
import { timeFormatter } from '@/utils'
const tableProps = [
@@ -168,7 +179,8 @@ export default {
{ label: '无法识别', value: 'iisrest' }
],
selectedGlassId: [],
detailMsg: {}
detailMsg: {},
defectList: {}
}
},
mounted() {
@@ -201,13 +213,29 @@ export default {
})
return false
}
if (this.checkList.length === 0) {
this.$message({
message: '请先勾选缺陷',
type: 'error',
duration: 1500,
onClose: () => {}
})
return false
}
this.getDetail()
drawPoint({
startTime: this.listQuery.startTime,
endTime: this.listQuery.endTime,
glassId: this.selectedGlassId
glassId: this.selectedGlassId,
defectType: this.checkList
}).then((res) => {
console.log(res)
if (res.code === 0) {
this.defectList = res.data
} else {
this.defectList = {}
}
this.$refs.poltChart.getChart()
})
},
getDetail() {
@@ -266,6 +294,63 @@ export default {
},
moveEnd() {
this.$refs.poltChart.getChart()
},
// 导出
exportExl() {
pointExport({
startTime: this.listQuery.startTime,
endTime: this.listQuery.endTime,
glassId: this.selectedGlassId,
defectType: this.checkList
}).then((response) => {
let fileName = ''
const contentDisposition = response.headers['content-disposition']
if (contentDisposition) {
fileName = decodeURIComponent(
contentDisposition.slice(
contentDisposition.indexOf('filename=') + 9
)
)
}
const blob = new Blob([response.data])
const reader = new FileReader()
reader.readAsDataURL(blob)
reader.onload = (e) => {
const a = document.createElement('a')
a.download = fileName
a.href = e.target.result
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
})
pointExport2({
startTime: this.listQuery.startTime,
endTime: this.listQuery.endTime,
glassId: this.selectedGlassId,
defectType: this.checkList
}).then((response) => {
let fileName = ''
const contentDisposition = response.headers['content-disposition']
if (contentDisposition) {
fileName = decodeURIComponent(
contentDisposition.slice(
contentDisposition.indexOf('filename=') + 9
)
)
}
const blob = new Blob([response.data])
const reader = new FileReader()
reader.readAsDataURL(blob)
reader.onload = (e) => {
const a = document.createElement('a')
a.download = fileName
a.href = e.target.result
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
})
}
}
}