mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect-embeded.git
synced 2025-06-24 05:24:12 +08:00
fixed
This commit is contained in:
parent
fcb7b463da
commit
8795da1093
@ -80,6 +80,8 @@
|
||||
"crypto-js": "^4.1.1",
|
||||
"dayjs": "^1.11.9",
|
||||
"echarts": "^5.4.2",
|
||||
"exceljs": "^4.4.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lodash.get": "^4.4.2",
|
||||
"mockjs": "^1.1.0",
|
||||
@ -109,6 +111,7 @@
|
||||
"@purge-icons/generated": "^0.9.0",
|
||||
"@types/codemirror": "^5.60.8",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/intro.js": "^5.1.1",
|
||||
"@types/lodash-es": "^4.17.7",
|
||||
"@types/lodash.get": "^4.4.7",
|
||||
|
@ -217,38 +217,48 @@
|
||||
reload();
|
||||
};
|
||||
|
||||
const handleView = (record: any) => {
|
||||
const getCode = (code1: string, code2: string) => {
|
||||
const hasPt = code1.indexOf("PT") !== -1;
|
||||
if (hasPt) {
|
||||
let code = code1.split("PT")[0] + "PT";
|
||||
for (let i = 0; i < code1.split("PT")[1].length - code2.length; i++) {
|
||||
code += "0";
|
||||
}
|
||||
code += code2;
|
||||
return code
|
||||
} else {
|
||||
return code2
|
||||
}
|
||||
};
|
||||
|
||||
const getResults = (record: any) => {
|
||||
const params = JSON.parse(record.paramJson);
|
||||
const result = JSON.parse(record.resultJson);
|
||||
if (record.resultJson === undefined || record.resultJson === null)
|
||||
return;
|
||||
result.forEach((items: any) => {
|
||||
items.forEach((d: any) => {
|
||||
params[d.code - 1].x1 = d.x1;
|
||||
params[d.code - 1].x2 = d.x2;
|
||||
params[d.code - 1].x3 = d.x3;
|
||||
params[d.code - 1].x4 = d.x4;
|
||||
params[d.code - 1].y1 = d.y1;
|
||||
params[d.code - 1].y2 = d.y2;
|
||||
params[d.code - 1].y3 = d.y3;
|
||||
params[d.code - 1].y4 = d.y4;
|
||||
params[d.code - 1].w = d.w;
|
||||
params[d.code - 1].h = d.h;
|
||||
params[d.code - 1].status = d.status;
|
||||
})
|
||||
if (record.results === undefined || record.results === null)
|
||||
return undefined;
|
||||
const results = JSON.parse(record.results);
|
||||
params.forEach((param: any) => {
|
||||
const l = results.filter((d: any) => param["code"] === getCode(param["code"], d["code"]+''));
|
||||
if (l.length > 0) {
|
||||
param["x1"] = l[0]["x1"];
|
||||
param["y1"] = l[0]["y1"];
|
||||
param["x2"] = l[0]["x2"];
|
||||
param["y2"] = l[0]["y2"];
|
||||
param["x3"] = l[0]["x3"];
|
||||
param["y3"] = l[0]["y3"];
|
||||
param["x4"] = l[0]["x4"];
|
||||
param["y4"] = l[0]["y4"];
|
||||
param["base"] = l[0]["base"];
|
||||
param["actual_value"] = l[0]["actual_value"];
|
||||
param["status"] = l[0]["status"];
|
||||
}
|
||||
});
|
||||
// params.forEach((d) => {
|
||||
// const r = Math.ceil(Math.random() * 10) - 3;
|
||||
// d.l1 = r + parseInt(d.w);
|
||||
// d.l2 = r + parseInt(d.h);
|
||||
// d.l3 = r + parseInt(d.w);
|
||||
// d.l4 = r + parseInt(d.h);
|
||||
// const x = parseInt(d.x) + d.l1 / 2;
|
||||
// const y = parseInt(d.y) + d.l2 / 2;
|
||||
// d.c = x + ' , ' + y;
|
||||
// d.result = r >= -2 && r <= 5 ? 'OK' : 'NG';
|
||||
// });
|
||||
record.resultJson1 = JSON.stringify(params);
|
||||
return params;
|
||||
}
|
||||
|
||||
const handleView = (record: any) => {
|
||||
const results = getResults(record);
|
||||
if (!results) return;
|
||||
record.resultJson1 = JSON.stringify(results);
|
||||
openModal(true, { record });
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,15 @@
|
||||
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="register" :closable="false" :showCancelBtn="false" okText="关闭" showFooter title="任务结果详情" width="1450px" @ok="closeModal">
|
||||
<BasicModal v-bind="$attrs" @register="register" width="1570px" :closable="false">
|
||||
<template #title>
|
||||
<div style="color: #ffffff; font-size: 16px; font-weight: normal;"><FileTextOutlined /> {{title}}</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<div style="padding-right: 30px;">
|
||||
<a-button :icon="h(FileExcelOutlined)" @click="handleExport">导出结果(Excel)</a-button>
|
||||
<a-button :icon="h(CloseOutlined)" @click="closeModal">关闭</a-button>
|
||||
</div>
|
||||
</template>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'status'">
|
||||
@ -14,9 +23,11 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { BasicModal, useModalInner } from "@/components/Modal";
|
||||
import {defineEmits, ref} from "vue";
|
||||
import {defineEmits, ref, h} from "vue";
|
||||
import {BasicTable, useTable,} from "@/components/Table";
|
||||
import { CheckOutlined, CloseOutlined } from "@ant-design/icons-vue";
|
||||
import { CheckOutlined, CloseOutlined, FileExcelOutlined, FileTextOutlined } from "@ant-design/icons-vue";
|
||||
import ExcelJS from 'exceljs';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@ -54,75 +65,89 @@ const columns = [
|
||||
width: '80px',
|
||||
},
|
||||
{
|
||||
title: '检测中心(mm)',
|
||||
dataIndex: 'c',
|
||||
key: 'c',
|
||||
title: '中心(m)',
|
||||
dataIndex: 'center',
|
||||
key: 'center',
|
||||
width: '110px',
|
||||
},
|
||||
{
|
||||
title: 'X1',
|
||||
dataIndex: 'x1',
|
||||
key: 'x1',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'Y1',
|
||||
dataIndex: 'y1',
|
||||
key: 'y1',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'X2',
|
||||
dataIndex: 'x2',
|
||||
key: 'x2',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'Y2',
|
||||
dataIndex: 'y2',
|
||||
key: 'y2',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'X3',
|
||||
dataIndex: 'x3',
|
||||
key: 'x3',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'Y3',
|
||||
dataIndex: 'y3',
|
||||
key: 'y3',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'X4',
|
||||
dataIndex: 'x4',
|
||||
key: 'x4',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: 'Y4',
|
||||
dataIndex: 'y4',
|
||||
key: 'y4',
|
||||
width: '40px',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: '标准值',
|
||||
dataIndex: 'base',
|
||||
key: 'base',
|
||||
width: '60px',
|
||||
},
|
||||
{
|
||||
title: '实际值',
|
||||
dataIndex: 'actual_value',
|
||||
key: 'actual_value',
|
||||
width: '70px',
|
||||
},
|
||||
{
|
||||
title: '结果',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: '80px',
|
||||
width: '50px',
|
||||
},
|
||||
];
|
||||
|
||||
const paramData = ref<any>([]);
|
||||
|
||||
const entity = ref();
|
||||
const title = ref("");
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
|
||||
const [register, { closeModal, setModalProps }] = useModalInner(async (data) => {
|
||||
setModalProps({ confirmLoading: false });
|
||||
entity.value = data?.record;
|
||||
title.value = data?.record.name + " - 任务结果详情";
|
||||
paramData.value = [];
|
||||
const items = entity.value && entity.value.resultJson ? JSON.parse(entity.value.resultJson1) : [];
|
||||
items.forEach((d: any, index: number) => {
|
||||
@ -143,6 +168,56 @@ const [registerTable] = useTable({
|
||||
rowKey: (record: any) => record.code,
|
||||
});
|
||||
|
||||
const handleExport = async () => {
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
const worksheet = workbook.addWorksheet('Sheet1');
|
||||
// 设置表头数据
|
||||
worksheet.addRow(columns.map((d: any) => (d["title"] || d["key"])));
|
||||
// 设置表头样式
|
||||
const headerRow = worksheet.getRow(1);
|
||||
setCellStyle(headerRow, true);
|
||||
// 添加数据
|
||||
paramData.value.forEach((param: any, index: number) => {
|
||||
let data: any = [];
|
||||
columns.forEach((d: any) => {
|
||||
let v = !param[d["key"]] ? "" : param[d["key"]];
|
||||
if (!!v && v === "good") {
|
||||
v = "✔"
|
||||
}
|
||||
if (!!v && v === "error") {
|
||||
v = "×"
|
||||
}
|
||||
data.push(v);
|
||||
});
|
||||
worksheet.addRow(data);
|
||||
setCellStyle(worksheet.getRow(index + 2));
|
||||
});
|
||||
worksheet.getColumn(1).width = 22;
|
||||
worksheet.getColumn(2).width = 22;
|
||||
// 导出文件
|
||||
const buffer = await workbook.xlsx.writeBuffer();
|
||||
const blob = new Blob([buffer], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
|
||||
saveAs(blob, title.value.replaceAll(" ", "") + '.xlsx');
|
||||
};
|
||||
|
||||
const setCellStyle = (row: any, isHeader: boolean = false) => {
|
||||
row.eachCell((cell: any) => {
|
||||
cell.fill = {
|
||||
type: 'pattern',
|
||||
pattern: 'solid',
|
||||
fgColor: isHeader ? {argb: 'FFD3D3D3'} : {argb: 'FFFFFFFF'}
|
||||
};
|
||||
cell.font = {
|
||||
bold: isHeader,
|
||||
color: isHeader ? {argb: 'FF000000'} : {argb: 'ff333333'}
|
||||
};
|
||||
cell.alignment = {vertical: 'middle', horizontal: 'center'};
|
||||
cell.border = {
|
||||
bottom: {style: 'thin', color: {argb: 'ff000000'}},
|
||||
right: {style: 'thin', color: {argb: 'ff000000'}},
|
||||
};
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@use '@/assets/custom.scss';
|
||||
|
@ -106,6 +106,15 @@ export const schema = {
|
||||
table: {
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'results',
|
||||
label: '结果',
|
||||
defaultValue: undefined,
|
||||
form: {
|
||||
},
|
||||
table: {
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'startTimeQuery',
|
||||
label: '开始时间',
|
||||
|
Loading…
Reference in New Issue
Block a user