369 lines
8.5 KiB
Vue

<template>
<view class="container">
<view class="construction_header">
<view class="container_title">
焊接合格率
</view>
<view class="right-top_header">
<view class="right-top_header_left">
<view @click="onContractorClick(item)" :class="{ active: contractorAssessmentInfo.id == item.id }"
v-for="item in contractorAssessmentList" :key="item.id">
{{ item.contractorAssessmentName }}
</view>
</view>
</view>
</view>
<view class="minCharts">
<view class="" v-if="columnarChart1.textDataX.length != 0">
<!-- <u-charts canvas-id="columnarChart1" chartType="column" :opts="columnarChart1" ref="columnarChart1"
:cWidth="cWidth" :cHeight="cHeight" :legends="false" /> -->
<qiun-data-charts type="column" :cWidth="cWidth" :cHeight="cHeight" :ontouch="true" :opts="opts"
:chartData="columnarChart1" />
</view>
<view class="no_data" v-if="columnarChart1.textDataX.length == 0">
<image src="/static/bthgIcon/noData.png"></image>
<view>暂无数据</view>
</view>
</view>
</view>
</template>
<script>
import uCharts from '@/components/u-charts/component.vue';
import {
isJSON,
pxToRpx
} from '@/utils/tool.js'
export default {
components: {
uCharts,
},
data() {
return {
projectSn: "",
cWidth: 0,
cHeight: 0,
columnarChart1: {
categories: [],
textDataX: [],
series: [{
// name: "温度",
data: []
}]
},
opts: {},
contractorAssessmentList: [{
id: 1,
contractorAssessmentName: '按装置'
},
{
id: 2,
contractorAssessmentName: '按人员'
}
],
contractorAssessmentInfo: {
id: 1
},
}
},
created() {
const that = this;
// uni.getSystemInfo({
// success: function(res) {
// that.cWidth = res.windowWidth - pxToRpx(10) - pxToRpx(24);
// }
// });
},
mounted() {
const that = this;
uni.getSystemInfo({
success: function(res) {
console.log(res.windowWidth);
console.log(11111, res.windowHeight);
that.cWidth = res.windowWidth - uni.upx2px(50) - uni.upx2px(44) - uni.upx2px(34);
that.cHeight = uni.upx2px(345 + 14)
}
});
this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
this.getDeviceScheduleList();
},
onShow() {
},
onLoad(options) {
},
methods: {
onContractorClick(row) {
this.contractorAssessmentInfo.id = row.id;
if (this.contractorAssessmentInfo.id == 1) {
this.getDeviceScheduleList();
} else {
this.getWeldingWorkerList();
}
},
getWeldingWorkerList() {
const that = this;
let data = {
projectSn: this.projectSn,
weldingPassRateDesc: 1
};
console.log(this.projectSn)
this.sendRequest({
url: 'xmgl/pipelineWelder/page',
data,
method: 'get',
success(res) {
if (res.code == 200) {
const dataX = res.result.records.map(item => item.welderName);
const dataY = res.result.records.map(item => Number(item.weldingPassRate));
// that.columnarChart1.textDataTitle = '%';
// that.columnarChart1.textDataX = res.result.records.map(item => item.welderName);
// that.columnarChart1.categories = dataX
// that.columnarChart1.series = [{
// // name: "温度",
// data: dataY
// }]
that.columnarChart1 = {
textDataTitle: '%',
textDataX: res.result.records.map(item => item.welderName),
categories: dataX,
series: [{
// name: "温度",
data: dataY
}]
}
that.opts = {
color: [
"#5181F6",
"#00DBB6",
"#F67F51",
"#FF515A",
"#8B5CFF",
"#00CA69",
],
padding: [uni.upx2px(30), 0, uni.upx2px(20), uni.upx2px(20)],
enableScroll: true,
animation: false,
duration: 0,
width: that.cWidth,
height: that.cHeight,
fontSize: uni.upx2px(22),
legend: {
show: false
},
xAxis: {
disableGrid: true,
itemCount: 4,
labelCount: that.columnarChart1.categories.length,
fontSize: uni.upx2px(22),
lineHeight: uni.upx2px(40),
format: "Xdemo",
// scrollShow: true,
},
yAxis: {
format: (val) => {
console.log(111, val);
if ((val + "").indexOf(".") != -1) {
return val.toFixed(0); //保留小数后1位
} else {
return val;
}
},
},
extra: {
column: {
type: "group",
width: uni.upx2px(28),
},
}
}
// that.$nextTick(() => {
// that.$refs.columnarChart1.changeData('columnarChart1', that.columnarChart1)
// })
}
}
})
},
getDeviceScheduleList() {
const that = this;
let data = {
projectSn: this.projectSn,
};
console.log(this.projectSn)
this.sendRequest({
url: 'xmgl/homePage/rankWeldingPassRate',
data,
method: 'post',
success(res) {
if (res.code == 200) {
const dataX = res.result.map(item => item.deviceUnitName);
const dataY = res.result.map(item => Number(item.weldingPassRate));
// that.columnarChart1.textDataTitle = '%';
// that.columnarChart1.textDataX = res.result.map(item => item.deviceUnitName);
// that.columnarChart1.categories = dataX
// that.columnarChart1.series = [{
// // name: "温度",
// data: dataY
// }]
that.columnarChart1 = {
textDataTitle: '%',
textDataX: res.result.map(item => item.deviceUnitName),
categories: dataX,
series: [{
// name: "温度",
data: dataY
}]
}
that.opts = {
color: [
"#5181F6",
"#00DBB6",
"#F67F51",
"#FF515A",
"#8B5CFF",
"#00CA69",
],
padding: [uni.upx2px(30), 0, uni.upx2px(20), uni.upx2px(20)],
enableScroll: true,
animation: false,
duration: 0,
width: that.cWidth,
height: that.cHeight,
legend: {
show: false
},
xAxis: {
disableGrid: true,
itemCount: 4,
labelCount: that.columnarChart1.categories.length,
fontSize: uni.upx2px(22),
lineHeight: uni.upx2px(40),
format: "Xdemo",
// scrollShow: true,
},
yAxis: {
format: (val) => {
console.log(111, val);
if ((val + "").indexOf(".") != -1) {
return val.toFixed(0); //保留小数后1位
} else {
return val;
}
},
},
extra: {
column: {
type: "group",
width: uni.upx2px(28),
},
}
}
// that.$nextTick(() => {
// that.$refs.columnarChart1.changeData('columnarChart1', that.columnarChart1)
// })
}
}
})
}
},
}
</script>
<style lang="scss" scoped>
.no_data {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
color: rgba(0, 0, 0, 0.5);
font-size: 28rpx;
uni-image {
width: 300rpx;
height: 300rpx;
display: block;
margin: 0 auto;
}
}
.container {
margin-top: 24rpx;
padding: 0 30rpx 20rpx;
.minCharts {
width: calc(100%);
// min-height: 345px;
min-height: calc(400rpx);
background: #FFFFFF;
box-shadow: 0px 10rpx 20rpx 0px rgba(46, 91, 255, 0.2);
border-radius: 8rpx;
border: 2rpx solid rgba(102, 111, 232, 0.08);
padding: 24rpx;
margin-top: 20rpx;
position: relative;
}
.construction_header {
display: flex;
justify-content: space-between;
}
.right-top_header {
display: flex;
align-items: center;
justify-content: space-between;
.right-top_header_left {
display: flex;
>view {
border: 1px solid #0056A8;
padding: 6rpx 12rpx;
font-size: 24rpx;
color: #0056a8;
cursor: pointer;
position: relative;
border-radius: 6rpx;
}
>view:not(:first-child) {
margin-left: 20rpx;
}
>view.active {
background-color: #2B8DF3;
border-color: #2B8DF3;
color: white;
}
}
}
}
.container_title {
font-size: 30rpx;
font-weight: bold;
position: relative;
margin-left: 20rpx;
margin-bottom: 16rpx;
margin-top: 32rpx;
color: #2D8EF3;
}
.container_title::after {
content: '';
position: absolute;
left: -20rpx;
top: 50%;
width: 4rpx;
height: 80%;
transform: translateY(-50%);
background-color: #2D8EF3;
}
</style>