projects/mes-zjl #384

Merged
juzi merged 4 commits from projects/mes-zjl into projects/mes-test 2024-07-26 15:06:26 +08:00
8 changed files with 312 additions and 1248 deletions
Showing only changes of commit d44c366a19 - Show all commits

View File

@ -38,3 +38,11 @@ export function getInspectionData(query) {
params: query,
})
}
export function getRecordInOneDay(query) {
return request({
url: '/analysis/record-in-one-day/get',
method: 'get',
params: query,
})
}

View File

@ -1,270 +0,0 @@
<!--
filename: dialogForm.vue
author: liubin
date: 2023-09-11 15:55:13
description: DialogForm for qualityInspectionRecord only
-->
<template>
<el-form
ref="form"
:model="innerDataForm"
label-width="100px"
v-loading="formLoading">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="检测内容"
prop="inspectionDetId"
:rules="[{ required: true, message: '检测内容不能为空', trigger: 'blur' }]">
<el-select
v-model="innerDataForm.inspectionDetId"
placeholder="请选择检测内容"
filterable
clearable
@change="handleInspectionDetChange">
<el-option
v-for="opt in inspectionDetList"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="来源"
prop="source"
:rules="[{ required: true, message: '来源不能为空', trigger: 'blur' }]">
<el-select
v-model="innerDataForm.source"
placeholder="请选择来源"
filterable
clearable
@change="$emit('update', innerDataForm)">
<el-option
v-for="opt in [
{ label: '手动', value: 1 },
{ label: '自动', value: 2 },
]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="产线"
prop="productionLineId"
:rules="[{ required: true, message: '产线不能为空', trigger: 'blur' }]">
<el-select
v-model="innerDataForm.productionLineId"
placeholder="请选择产线"
filterable
clearable
@change="handleProductlineChange">
<el-option
v-for="opt in productionLineList"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="工段"
prop="sectionId"
:rules="[{ required: true, message: '工段不能为空', trigger: 'blur' }]">
<el-select
v-model="innerDataForm.sectionId"
placeholder="请选择工段"
clearable
filterable
@change="$emit('update', innerDataForm)">
<el-option
v-for="opt in sectionList"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="检测人员" prop="checkPerson">
<el-input
v-model="innerDataForm.checkPerson"
clearable
@change="$emit('update', innerDataForm)"
placeholder="请输入检测人员" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="检测时间"
prop="checkTime"
:rules="[{ required: true, message: '检测时间不能为空', trigger: 'blur' }]">
<el-date-picker
v-model="innerDataForm.checkTime"
type="datetime"
placeholder="请选择检测时间"
value-format="timestamp"
@change="$emit('update', innerDataForm)"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col>
<el-form-item label="描述" prop="explainText">
<el-input
v-model="innerDataForm.explainText"
placeholder="请输入描述信息"
@change="$emit('update', innerDataForm)"
type="textarea"></el-input>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="备注" prop="remark">
<el-input
v-model="innerDataForm.remark"
@change="$emit('update', innerDataForm)"
placeholder="请输入备注"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
name: 'DialogForm',
model: {
prop: 'dataForm',
event: 'update',
},
emits: ['update'],
components: {},
props: {
dataForm: {
type: Object,
default: () => ({}),
},
},
data() {
return {
formLoading: true,
inspectionDetList: [],
productionLineList: [],
sectionList: [],
innerDataForm: {},
cacheInspectionDetList: null,
};
},
mounted() {
Promise.all([this.getProductLineList(), this.getInspectionDetList()]).then(
() => {
this.formLoading = false;
}
);
},
watch: {
// 'innerDataForm.productionLineId': {
// handler: async function (plId) {
// if (plId) await this.getWorksectionList(plId);
// },
// immediate: true,
// },
dataForm: {
handler: function (dataForm) {
this.innerDataForm = Object.assign({}, dataForm);
if (dataForm.productionLineId)
this.getWorksectionList(dataForm.productionLineId);
},
immediate: true,
},
},
methods: {
/** 模拟透传 ref */
validate(cb) {
return this.$refs.form.validate(cb);
},
resetFields(args) {
return this.$refs.form.resetFields(args);
},
handleInspectionDetChange(value) {
const { id, content } = this.cacheInspectionDetList.find(
(item) => item.id == value
);
this.innerDataForm.inspectionDetId = id;
this.innerDataForm.inspectionDetContent = content;
this.$emit('update', this.innerDataForm);
},
async handleProductlineChange(id) {
// await this.getWorksectionList(id);
this.innerDataForm.sectionId = null;
this.$emit('update', this.innerDataForm);
},
// getCode
async getCode(url) {
const response = await this.$axios(url);
return response.data;
},
// 线
async getProductLineList() {
const response = await this.$axios('/base/core-production-line/listAll');
this.productionLineList = response.data.map((item) => ({
label: item.name,
value: item.id,
}));
},
//
async getInspectionDetList() {
const response = await this.$axios(
'/base/quality-inspection-det/listAll'
);
this.cacheInspectionDetList = response.data;
this.inspectionDetList = response.data.map((item) => ({
label: item.content,
value: item.id,
}));
},
//
async getWorksectionList(plId) {
const response = await this.$axios(
'/base/workshop-section/listByParentId',
{
params: {
id: plId,
},
}
);
this.sectionList = response.data.map((item) => ({
label: item.name,
value: item.id,
}));
},
},
};
</script>
<style scoped lang="scss">
.el-date-editor,
.el-select {
width: 100%;
}
</style>

View File

@ -1,649 +0,0 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<!-- 列表 -->
<el-row>
<el-col class="custom-tabs">
<el-tabs
v-model="activeName"
:stretch="true"
@tab-click="handleTabClick">
<el-tab-pane :label="'\u2002表格数据\u2002'" name="table">
<!-- 列表 -->
<div class="blue-title">
产品名{{ productDetail.name }} 产品规格{{
productDetail.specifications
}}
</div>
<base-table
class="base-table__margin"
:table-props="productProps"
:page="1"
:limit="10"
:table-data="list"></base-table>
<div v-for="(item, index) in downProps" :key="index">
<div class="blue-title">
工单名称:{{ list[index].workOrderName }}
</div>
<base-table
class="base-table__margin"
:table-props="item"
:page="1"
:limit="10"
:table-data="downList[index]"></base-table>
</div>
</el-tab-pane>
<el-tab-pane
:label="'\u3000图形数据\u3000'"
name="chart"
style="overflow: inherit">
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick" />
<div id="main" style="height: 500px; width: 1000px"></div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
<!-- 分页组件 -->
<!-- <pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" /> -->
<!-- 对话框(添加 / 修改) -->
<!-- <base-dialog
:dialogTitle="title"
:dialogVisible="open"
width="50%"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" v-model="form" />
</base-dialog> -->
</div>
</template>
<script>
import {
getInspectionData,
getProductList,
getWorkOrderList,
} from '@/api/monitoring/statisticalData';
// import Editor from '@/components/Editor';
import moment from 'moment';
// import DialogForm from './dialogForm.vue';
import * as echarts from 'echarts';
// import basicPageMixin from '@/mixins/lb/basicPageMixin';
export default {
name: 'statisticalData',
// components: {
// DialogForm,
// },
// mixins: [basicPageMixin],
data() {
return {
list: [],
dynamicProps: [],
downProps: [],
downList: [],
productDetail: {
name: null,
specifications: null,
},
activeName: 'table',
searchBarFormConfig: [
{
type: 'label',
label: '当前检测数据柱状图',
// placeholder: '',
// param: 'workOrderId',
// selectOptions: [],
},
// {
// type: 'select',
// label: '',
// placeholder: '',
// param: 'productionId',
// selectOptions: [],
// },
// {
// type: 'input',
// label: '',
// placeholder: '',
// param: 'inspectionDetContent',
// },
// {
// type: 'datePicker',
// label: '',
// dateType: 'daterange', // datetimerange
// // format: 'yyyy-MM-dd HH:mm:ss',
// format: 'yyyy-MM-dd',
// valueFormat: 'timestamp',
// rangeSeparator: '-',
// startPlaceholder: '',
// endPlaceholder: '',
// defaultTime: ['00:00:00', '23:59:59'],
// param: 'checkTime',
// // width: 350,
// },
// {
// type: 'button',
// btnName: '',
// name: 'search',
// color: 'primary',
// },
// {
// type: 'separate',
// },
// // {
// // type: this.$auth.hasPermi(
// // 'base:quality-inspection-record:create'
// // )
// // ? 'button'
// // : '',
// // btnName: '',
// // name: 'add',
// // plain: true,
// // color: 'success',
// // },
],
// tableBtn: [
// this.$auth.hasPermi('base:quality-inspection-record:update')
// ? {
// type: 'edit',
// btnName: '',
// }
// : undefined,
// this.$auth.hasPermi('base:quality-inspection-record:delete')
// ? {
// type: 'delete',
// btnName: '',
// }
// : undefined,
// ].filter((v) => v),
// tableProps: [
// {
// prop: 'createTime',
// label: '',
// fixed: true,
// width: 180,
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
// },
// {
// // width: 128,
// prop: 'inspectionDetContent',
// label: '',
// },
// {
// // width: 128,
// prop: 'lineName',
// label: '线',
// },
// {
// // width: 128,
// prop: 'checkPerson',
// label: '',
// },
// {
// // width: 160,
// prop: 'checkTime',
// label: '',
// filter: (val) =>
// val != null ? moment(val).format('yyyy-MM-DD HH:mm:ss') : '-',
// },
// {
// width: 90,
// prop: 'source',
// label: '',
// filter: (val) => ['', '', ''][val],
// },
// ],
// keys, queryParams pageNo, pageSize key
// searchBarKeys: ['inspectionDetContent', 'checkTime', 'productionLineId'],
// form: {
// id: undefined,
// inspectionDetId: undefined,
// inspectionDetContent: undefined,
// productionLineId: undefined,
// sectionId: undefined,
// checkPerson: undefined,
// checkTime: undefined,
// source: undefined,
// explainText: undefined,
// remark: undefined,
// },
//
queryParams: {
workOrderId: undefined,
productId: undefined,
startTime: undefined,
endTime: undefined,
// productionLineId: null,
},
};
},
created() {
// this.getProductLineList();
},
computed: {
productProps() {
return [
{
// width: 160,
prop: 'workOrderName',
label: '工单名称',
},
...this.dynamicProps,
{
// width: 128,
prop: 'sumInput',
label: '上片总数',
},
{
// width: 128,
prop: 'sumOutput',
label: '下片总数',
// subcomponent: {
// name: 'TextOnly',
// props: {
// injectData: {
// type: Object,
// default: () => ({}),
// },
// },
// data() {
// return {
// text: '',
// };
// },
// methods: {
// handleEmit(payload) {
// console.log('handleEmit', payload);
// },
// },
// render(h) {
// return h('el-button', { props: { type: 'text' } }, this.text);
// },
// },
},
];
},
},
mounted() {
if (this.$route.params.startTime && this.$route.params.endTime) {
this.searchBarFormConfig[0].defaultSelect = [
this.$route.params.startTime,
this.$route.params.endTime,
];
this.queryParams.param = {};
this.$set(
this.queryParams.param,
'startTime',
this.$route.params.startTime
);
this.$set(this.queryParams.param, 'endTime', this.$route.params.endTime);
} else {
this.searchBarFormConfig[0].defaultSelect = [];
}
this.getList();
},
methods: {
handleTabClick() {
if (this.activeName === 'chart') {
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
let arrXAxis = [];
this.list.forEach((ele) => {
arrXAxis.push(ele.workOrderName);
});
this.downList.forEach((ele) => {
ele.forEach((item) => {
if (ele.length !== 0 && item.productionline) {
arrXAxis.push('产线' + item.productionline);
}
});
});
let arrYAxis = [];
this.list.forEach((ele) => {
// console.log(ele);
arrYAxis.push(ele.sumInput);
});
this.downList.forEach((ele) => {
ele.forEach((item) => {
console.log(item);
// if (ele.length !== 0 && item.productionline) {
arrYAxis.push(item.sumInput);
// }
});
});
// console.log(arrXAxis);
option = {
xAxis: {
type: 'category',
data: arrXAxis,
},
yAxis: {
type: 'value',
},
series: [
{
data: arrYAxis,
type: 'bar',
showBackground: true,
barWidth: '20',
label: {
show: true,
position: 'top',
},
backgroundStyle: {
color: 'rgba(180, 180, 180, 0.2)',
},
},
],
};
option && myChart.setOption(option);
}
},
/** 获取搜索栏的产线列表 */
// async getDict() {
// const res = await getProductList()
// const result = await getWorkOrderList()
// console.log(res);
// this.searchBarFormConfig[1].selectOptions = res.data.map((item) => {
// return {
// name: item.name,
// id:item.id
// }
// })
// this.searchBarFormConfig[0].selectOptions = result.data.map((item) => {
// return {
// name: item.name,
// id: item.id
// }
// })
// },
// getProductLineList() {
// this.$axios('/base/production-line/listAll').then((response) => {
// this.searchBarFormConfig[0].selectOptions = response.data.map(
// (item) => {
// return {
// name: item.name,
// id: item.id,
// };
// }
// );
// });
// },
getList() {
this.getDataList();
// this.getDict()
},
/** 查询列表 */
async getDataList() {
this.loading = true;
//
this.downProps = [];
const res = await getInspectionData(this.queryParams);
console.log(res);
this.productDetail.name = res.data[0].productName;
this.productDetail.specifications = res.data[0].specifications;
// this.productName = res.data[0].productName
this.dynamicProps = this.filterNameData(res.data[0].upPart.nameData);
console.log(this.dynamicProps);
this.list = this.filterData(res.data[0].upPart.data);
console.log(this.list);
res.data[0].downPart.forEach((ele) => {
// console.log(ele.data);
let arr = this.downFilterNameData(ele.nameData);
if (arr.length !== 0) {
let propArr = [
{
// width: 160,
prop: 'inspectionContent',
label: '检测内容',
},
...arr,
{
// width: 128,
prop: 'sumInput',
label: '原片总数',
},
{
// width: 128,
prop: 'sumScrap',
label: '未通过检测总数',
},
{
// width: 128,
prop: 'scrapRatio',
label: '报废比例',
},
];
this.downProps.push(propArr);
}
// this.downProps = []
});
res.data[0].downPart.forEach((ele) => {
// console.log(ele.data);
let arr = this.downFilterData(ele.data);
if (arr.length !== 0) {
this.downList.push(arr);
}
// this.downProps = []
});
// console.log(this.downList);
},
downFilterNameData(nameData) {
const ndSet = new Set();
nameData.forEach((nd) => {
ndSet.add(nd.name);
});
return Array.from(ndSet.values())
.sort()
.map((name) => ({
prop: name,
label: name,
}));
// })
},
downFilterData(data) {
return data.map((item) => {
const { data: innerData } = item;
const keyValuePairs = {};
innerData.map((d) => {
keyValuePairs[d.dynamicName] = d.dynamicValue;
});
return {
inspectionContent: item.inspectionContent,
...keyValuePairs,
sumInput: item.sumInput,
scrapRatio: item.scrapRatio,
sumScrap: item.sumScrap,
};
});
},
filterNameData(nameData) {
// console.log(upData);
// upData.forEach((ele) => {
const ndSet = new Set();
nameData.forEach((nd) => {
ndSet.add(nd.name);
});
return Array.from(ndSet.values())
.sort()
.map((name) => ({
prop: name,
label: name,
}));
// })
},
filterData(data) {
return data.map((item) => {
const { data: innerData } = item;
const keyValuePairs = {};
innerData.map((d) => {
keyValuePairs[d.dynamicName] = d.dynamicValue;
});
return {
inspectionContent: item.inspectionContent,
workOrderName: item.workOrderName,
...keyValuePairs,
sumInput: item.sumInput,
sumOutput: item.sumOutput,
};
});
},
/** 取消按钮 */
handleSearchBarBtnClick(val) {
if (val.btnName === 'search') {
this.queryParams.workOrderId = val.workOrderId
? val.workOrderId
: undefined;
this.queryParams.productId = val.productId ? val.productId : undefined;
this.queryParams.startTime = val.checkTime
? val.checkTime[0]
: undefined;
this.queryParams.endTime = val.checkTime ? val.checkTime[1] : undefined;
this.getList();
}
console.log(val);
},
/** 搜索按钮操作 */
// handleQuery() {
// this.queryParams.pageNo = 1;
// this.getList();
// },
// /** */
// resetQuery() {
// this.resetForm('queryForm');
// this.handleQuery();
// },
// /** */
// handleAdd() {
// this.reset();
// this.open = true;
// this.title = '';
// },
// /** */
// handleUpdate(row) {
// this.reset();
// const id = row.id;
// getQualityInspectionRecord(id).then((response) => {
// /** */
// const info = {}
// Object.keys(this.form).forEach(key => {
// info[key] = response.data[key]
// });
// this.form = info;
// this.open = true;
// this.title = '';
// });
// },
// /** */
// submitForm() {
// this.$refs['form'].validate((valid) => {
// if (!valid) {
// return;
// }
// //
// if (this.form.id != null) {
// updateQualityInspectionRecord(this.form).then((response) => {
// this.$modal.msgSuccess('');
// this.open = false;
// this.getList();
// });
// return;
// }
// //
// createQualityInspectionRecord(this.form).then((response) => {
// this.$modal.msgSuccess('');
// this.open = false;
// this.getList();
// });
// });
// },
// /** */
// handleDelete(row) {
// const id = row.id;
// this.$modal
// .confirm('"' + row.inspectionDetContent + '"?')
// .then(function () {
// return deleteQualityInspectionRecord(id);
// })
// .then(() => {
// this.getList();
// this.$modal.msgSuccess('');
// })
// .catch(() => {});
// },
// /** */
// handleExport() {
// //
// let params = { ...this.queryParams };
// params.pageNo = undefined;
// params.pageSize = undefined;
// this.$modal
// .confirm('?')
// .then(() => {
// this.exportLoading = true;
// return exportQualityInspectionRecordExcel(params);
// })
// .then((response) => {
// this.$download.excel(response, '.xls');
// this.exportLoading = false;
// })
// .catch(() => {});
// },
},
};
</script>
<style scoped lang="scss">
:deep(.custom-tabs) {
.el-tabs__header {
margin-bottom: 8px;
display: inline-block;
transform: translateY(-12px);
}
.el-tabs__content {
overflow: visible;
}
.el-tabs__item {
padding-left: 0 !important;
padding-right: 0 !important;
line-height: 36px !important;
height: 36px;
}
}
.blue-title {
position: relative;
padding: 4px 0;
padding-left: 12px;
font-size: 14px;
color: #606266;
font-weight: 700;
margin-bottom: 12px;
&::before {
content: '';
position: absolute;
left: 0;
top: 6px;
height: 16px;
width: 4px;
border-radius: 1px;
background: #0b58ff;
}
}
</style>

View File

@ -1,5 +1,7 @@
<template>
<div id="currentDataChart" style="width: 100%; height: 300px"></div>
<div
:id="'currentDataChart' + chartN"
style="width: 100%; height: 300px"></div>
</template>
<script>
import * as echarts from 'echarts';
@ -13,24 +15,36 @@ export default {
chart: '',
};
},
// props: {
// chartData: {
// type: Array,
// required: true,
// default: () => {
// return [];
// },
// },
// },
// watch: {
// chartData: function () {
// this.getChart();
// },
// },
mounted() {
window.addEventListener('resize', () => {
props: {
chartData: {
type: Array,
required: true,
default: () => {
return [];
},
},
lineName: {
type: Array,
required: true,
default: () => {
return [];
},
},
chartN: {
type: Number,
required: true,
default: () => {
return 0;
},
},
},
watch: {
chartData: function () {
this.getChart();
});
},
},
mounted() {
this.getChart();
},
methods: {
getChart() {
@ -41,11 +55,32 @@ export default {
) {
this.chart.dispose(); // Dom
}
this.chartDom = document.getElementById('currentDataChart');
this.chartDom = document.getElementById('currentDataChart' + this.chartN);
this.chart = echarts.init(this.chartDom);
// if (this.chartData.length === 0) {
// return false;
// }
if (this.chartData.length === 0) {
return false;
}
console.log('chartData:', this.chartData);
console.log('lineName:', this.lineName);
let xData = this.chartData.map((item) => {
return item.inspectionContent;
});
console.log('xData:', xData);
let series = [];
this.lineName.map((item) => {
let obj = {
data: [],
type: 'bar',
stack: 'a',
barWidth: 20,
name: item.prop,
};
this.chartData.forEach((ele) => {
obj.data.push(ele[item.prop]);
});
series.push(obj);
});
console.log('series:', series);
var option = {
color: [
'#288AFF',
@ -59,63 +94,31 @@ export default {
'#D680FF',
'#0043D2',
],
// legend: {
// data: keys,
// right: '1%',
// },
legend: {
itemWidth: 10,
itemHeight: 10,
textStyle: {
color: '#8c8c8c',
},
right: 0,
},
tooltip: {
trigger: 'axis',
},
grid: {
left: '1%',
right: '1%',
left: 20,
right: 0,
bottom: '3%',
containLabel: true,
},
xAxis: {
type: 'category',
data: ['1', '2', '3', '4', '5'],
data: xData,
},
yAxis: {
type: 'value',
},
series: [
{
data: [50, 30, 40, 50, 60],
type: 'bar',
stack: 'a',
barWidth: 20,
name: '产线1',
},
{
data: [30, 50, 44, 52, 39],
type: 'bar',
stack: 'a',
barWidth: 20,
name: '产线2',
},
{
data: [53, 33, 43, 53, 63],
type: 'bar',
stack: 'a',
barWidth: 20,
name: '产线3',
},
{
data: [35, 39, 44, 65, 45],
type: 'bar',
stack: 'a',
barWidth: 20,
name: '产线4',
},
{
data: [50, 30, 40, 50, 60],
type: 'bar',
stack: 'a',
barWidth: 20,
name: '产线5',
},
],
series: series,
};
option && this.chart.setOption(option);

View File

@ -5,133 +5,182 @@
:page="1"
:limit="1000"
:table-data="list" />
<div class="orderBox">
<div class="orderBox" v-for="(item, index) in downList" :key="index">
<div class="title">
<span>工单工单1</span>
<span>产品名称名称1</span>
<span>规格规格1</span>
<span>工单{{ item.workOrderName }}</span>
<span>产品名称{{ item.productionName }}</span>
<span>规格{{ item.productionSize }}</span>
</div>
<div class="custom-tabs">
<el-tabs v-model="activeName" :stretch="true">
<el-tab-pane :label="'\u2002表格\u2002'" name="table">
<!-- 列表 -->
<base-table
:table-props="tableProps2"
:page="1"
:limit="1000"
:table-data="list2" />
</el-tab-pane>
<el-tabs v-model="item.activeName" :stretch="true">
<el-tab-pane :label="'\u2002表格\u2002'" name="table"></el-tab-pane>
<el-tab-pane
:label="'\u3000图表\u3000'"
name="chart"
style="overflow: inherit">
<baseChart />
</el-tab-pane>
style="overflow: inherit"></el-tab-pane>
</el-tabs>
<!-- 列表 -->
<base-table
v-if="item.activeName === 'table'"
:table-props="item.tableProps"
:page="1"
:limit="1000"
:table-data="item.list"
:height="300" />
<baseChart
v-else
:chartN="index"
:chartData="item.list"
:lineName="item.downProps" />
</div>
</div>
</div>
</template>
<script>
import BaseChart from './baseChart.vue';
import { getInspectionData } from '@/api/monitoring/statisticalData';
export default {
name: 'CurrentTest',
components: { BaseChart },
data() {
return {
activeName: 'table',
tableProps: [
computed: {
tableProps() {
return [
{
prop: 'workOrderName',
label: '工单名称',
showOverflowtooltip: true,
},
...this.dynamicProps,
{
prop: 'prodName',
label: '产品名称',
showOverflowtooltip: true,
},
{
prop: 'line1',
label: '产线1',
showOverflowtooltip: true,
},
{
prop: 'line2',
label: '产线2',
showOverflowtooltip: true,
},
{
prop: 'line3',
label: '产线3',
showOverflowtooltip: true,
},
{
prop: 'total',
prop: 'sumInput',
label: '上片总数',
showOverflowtooltip: true,
},
{
prop: 'total2',
prop: 'sumOutput',
label: '下片总数',
showOverflowtooltip: true,
},
],
list: [
{ workOrderName: '工单1' },
{ workOrderName: '工单2' },
{ workOrderName: '工单3' },
{ workOrderName: '工单4' },
{ workOrderName: '工单5' },
{ workOrderName: '工单6' },
],
tableProps2: [
{
prop: 'workOrderName',
label: '检测内容',
showOverflowtooltip: true,
},
{
prop: 'prodName',
label: '原片总数',
showOverflowtooltip: true,
},
{
prop: 'line1',
label: '产线1',
showOverflowtooltip: true,
},
{
prop: 'line2',
label: '产线2',
showOverflowtooltip: true,
},
{
prop: 'line3',
label: '产线3',
showOverflowtooltip: true,
},
{
prop: 'total',
label: '未通过检测总数',
showOverflowtooltip: true,
},
{
prop: 'total2',
label: '报废比例',
showOverflowtooltip: true,
},
],
list2: [
{ workOrderName: '工单1' },
{ workOrderName: '工单2' },
{ workOrderName: '工单3' },
{ workOrderName: '工单4' },
{ workOrderName: '工单5' },
{ workOrderName: '工单6' },
],
];
},
},
data() {
return {
dynamicProps: [],
list: [],
downList: [],
};
},
mounted() {
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
const res = await getInspectionData();
// const res = {
// data: [],
// };
if (res.data && res.data.length > 0) {
this.dynamicProps = this.filterNameData(res.data[0].upPart.nameData);
this.list = this.filterData(res.data[0].upPart.data);
//
res.data.forEach((item) => {
let downProps = this.filterNameData(item.downPart[0].nameData);
console.log('downProps:', downProps);
let obj = this.downPartData(item.downPart[0].data, downProps);
obj.tableProps = [
{
prop: 'inspectionContent',
label: '检测内容',
showOverflowtooltip: true,
},
{
prop: 'sumInput',
label: '原片总数',
showOverflowtooltip: true,
},
...downProps,
{
prop: 'sumScrap',
label: '未通过检测总数',
},
{
prop: 'scrapRatio',
label: '报废比例',
},
];
this.downList.push(obj);
});
console.log(this.downList);
} else {
this.list = [];
this.dynamicProps = [];
}
},
filterNameData(nameData) {
const ndSet = new Set();
nameData.forEach((nd) => {
ndSet.add(nd.name);
});
return Array.from(ndSet.values())
.sort()
.map((name) => ({
prop: name,
label: name,
}));
},
filterData(data) {
return data.map((item) => {
const { data: innerData } = item;
const keyValuePairs = {};
console.log('innerData:', innerData);
this.dynamicProps.map((item) => {
keyValuePairs[item.prop] = '-';
});
innerData.forEach((d) => {
keyValuePairs[d.dynamicName] = d.dynamicValue;
});
return {
inspectionContent: item.inspectionContent,
workOrderName: item.workOrderName,
...keyValuePairs,
sumInput: item.sumInput,
sumOutput: item.sumOutput,
};
});
},
downPartData(data, downProps) {
let obj = {
workOrderName: '',
productionName: '',
productionSize: '',
activeName: 'table',
tableProps: [],
downProps: downProps,
list: [],
};
obj.workOrderName = data[0].workOrderName;
obj.productionName = data[0].productionName;
obj.productionSize = data[0].productionSize;
obj.list = data.map((item) => {
const { data: innerData } = item;
const keyValuePairs = {};
downProps.map((item) => {
keyValuePairs[item.prop] = '-';
});
innerData.map((d) => {
keyValuePairs[d.dynamicName] = d.dynamicValue;
});
return {
inspectionContent: item.inspectionContent,
sumInput: item.sumInput,
...keyValuePairs,
sumScrap: item.sumScrap,
scrapRatio: item.scrapRatio,
};
});
return obj;
},
},
};
</script>
<style scoped lang="scss">
@ -139,11 +188,27 @@ export default {
padding-top: 16px;
}
.title {
position: relative;
padding: 4px 0;
padding-left: 12px;
font-size: 14px;
color: #606266;
font-weight: 700;
margin-bottom: 12px;
&::before {
content: '';
position: absolute;
left: 0;
top: 6px;
height: 16px;
width: 4px;
border-radius: 1px;
background: #0b58ff;
}
span {
display: inline-block;
width: 300px;
font-size: 14px;
padding-bottom: 10px;
}
}
:deep(.custom-tabs) {

View File

@ -6,174 +6,81 @@
</template>
<script>
import tableHeightMixin from '@/mixins/tableHeightMixin';
import { getRecordInOneDay } from '@/api/monitoring/statisticalData';
import moment from 'moment';
export default {
name: 'HourData',
mixins: [tableHeightMixin],
computed: {
tableProps() {
return [
{
prop: 'inspectionDetContent',
label: '检测内容',
},
...this.nameData,
];
},
},
data() {
return {
heightNum: 200,
tableProps: [
{
prop: 'name',
lable: '检测内容',
},
{
label: '2024-01-01 01:00:00',
children: [
{
prop: 'line1-1',
label: '产线1',
},
{
prop: 'line1-2',
label: '产线2',
},
{
prop: 'line1-3',
label: '产线3',
},
{
prop: 'line1-4',
label: '产线4',
},
],
},
{
label: '2024-01-01 02:00:00',
children: [
{
prop: 'line2-1',
label: '产线1',
},
{
prop: 'line2-2',
label: '产线2',
},
{
prop: 'line2-3',
label: '产线3',
},
{
prop: 'line2-4',
label: '产线4',
},
],
},
{
label: '2024-01-01 03:00:00',
children: [
{
prop: 'line3-1',
label: '产线1',
},
{
prop: 'line3-2',
label: '产线2',
},
{
prop: 'line3-3',
label: '产线3',
},
{
prop: 'line3-4',
label: '产线4',
},
],
},
],
list: [
{
name: '磨边缺陷数',
'line1-1': 1,
'line1-2': 2,
'line1-3': 3,
'line1-4': 4,
'line2-1': 5,
'line2-2': 6,
'line2-3': 7,
'line2-4': 8,
'line3-1': 9,
'line3-2': 10,
'line3-3': 11,
'line3-4': 12,
},
{
name: '磨边缺陷数',
'line1-1': 1,
'line1-2': 2,
'line1-3': 3,
'line1-4': 4,
'line2-1': 5,
'line2-2': 6,
'line2-3': 7,
'line2-4': 8,
'line3-1': 9,
'line3-2': 10,
'line3-3': 11,
'line3-4': 12,
},
{
name: '磨边缺陷数',
'line1-1': 1,
'line1-2': 2,
'line1-3': 3,
'line1-4': 4,
'line2-1': 5,
'line2-2': 6,
'line2-3': 7,
'line2-4': 8,
'line3-1': 9,
'line3-2': 10,
'line3-3': 11,
'line3-4': 12,
},
{
name: '磨边缺陷数',
'line1-1': 1,
'line1-2': 2,
'line1-3': 3,
'line1-4': 4,
'line2-1': 5,
'line2-2': 6,
'line2-3': 7,
'line2-4': 8,
'line3-1': 9,
'line3-2': 10,
'line3-3': 11,
'line3-4': 12,
},
{
name: '磨边缺陷数',
'line1-1': 1,
'line1-2': 2,
'line1-3': 3,
'line1-4': 4,
'line2-1': 5,
'line2-2': 6,
'line2-3': 7,
'line2-4': 8,
'line3-1': 9,
'line3-2': 10,
'line3-3': 11,
'line3-4': 12,
},
{
name: '磨边缺陷数',
'line1-1': 1,
'line1-2': 2,
'line1-3': 3,
'line1-4': 4,
'line2-1': 5,
'line2-2': 6,
'line2-3': 7,
'line2-4': 8,
'line3-1': 9,
'line3-2': 10,
'line3-3': 11,
'line3-4': 12,
},
],
nameData: [],
list: [],
};
},
mounted() {
this.getList();
},
methods: {
async getList() {
const res = await getRecordInOneDay();
if (res.data) {
this.nameData = this.filterNameData(res.data.nameData);
this.list = this.filterData(res.data.data);
} else {
this.nameData = [];
this.list = [];
}
},
filterNameData(nameData) {
let arr = [];
nameData.forEach((ele) => {
if (ele.tree === 1) {
arr.push({
prop: ele.id,
label: moment(ele.name).format('yyyy-MM-DD HH:mm:ss'),
});
}
});
nameData.forEach((ele) => {
arr.forEach((inner) => {
if (ele.parentId === inner.prop) {
inner.children = [
{
prop: ele.parentId + ele.name,
label: ele.name,
},
];
}
});
});
return arr;
},
filterData(data) {
let list = [];
data.forEach((ele) => {
let obj = {};
obj.inspectionDetContent = ele.inspectionDetContent;
ele.data.forEach((inner) => {
inner.children.forEach((item) => {
obj[item.parentId + item.dynamicName] = item.dynamicValue;
});
});
list.push(obj);
});
return list;
},
},
};
</script>

View File

@ -120,7 +120,7 @@ export default {
this.$auth.hasPermi('base:quality-inspection-record:update')
? {
type: 'edit',
btnName: '修改',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi('base:quality-inspection-record:delete')

View File

@ -157,7 +157,7 @@ export default {
type: 'separate',
},
{
type: this.$auth.hasPermi('base:quality-scrap-det:create')
type: this.$auth.hasPermi('base:quality-scrap-log:create')
? 'button'
: '',
btnName: '新增',