|
|
@@ -63,7 +63,7 @@
|
|
|
<!-- 左右布局 -->
|
|
|
<layout style="height: calc(100% - 50px); display: flex;">
|
|
|
<layout-sider>
|
|
|
- <div class="JKWTree-tree" style="height: 100%; max-height: 100vh; overflow-y: auto;">
|
|
|
+ <div class="JKWTree-tree" style="height: 100%; max-height: 75vh; overflow-y: auto;">
|
|
|
<h3></h3>
|
|
|
<div v-if="useDateNav && dateTree.length" class="os-date-dates">
|
|
|
<template v-for="(y, yi) in dateTree" :key="'y-' + yi + '-' + y.year">
|
|
|
@@ -115,6 +115,7 @@
|
|
|
<layout-content style="flex: 1; overflow: auto;">
|
|
|
<el-main>
|
|
|
<div style="display: flex; justify-content: right;">
|
|
|
+ <!-- <el-button type="success" class="bt" style="width: 90px;" :loading="inspectionLoading" @click="onInspectionReport">检验报表</el-button> -->
|
|
|
<el-button type="primary" class="bt" style="width: 60px;" @click="pd_gdprintonClick" >工单打印</el-button>
|
|
|
<el-button type="danger" style="color: white;width: 60px;" @click="ontuicclick" class="bt" title="退出">退出</el-button>
|
|
|
</div>
|
|
|
@@ -166,7 +167,7 @@
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<el-tab-pane label="制程检验记录" @click="showTable('制程检验记录')" name="second">
|
|
|
- <el-table tooltip-effect="dark" :data="zcjyjltableData" row-key="ID"
|
|
|
+ <el-table tooltip-effect="dark" :data="zcjyjltableData" row-key="检验时间"
|
|
|
highlight-current-row="true" empty-text="未找到该流程制程检验记录"
|
|
|
class="custom-table"
|
|
|
:row-style="{ height: '0px' }" :header-cell-style="{ padding: '0px' }"
|
|
|
@@ -178,13 +179,14 @@
|
|
|
<el-table-column align="left" label="工序名称" width="260" prop="工序名称" />
|
|
|
<el-table-column align="left" label="班组编号" width="100" prop="班组编号" />
|
|
|
<el-table-column align="left" label="类别" width="160" prop="类别" />
|
|
|
- <el-table-column align="left" label="检验项目" width="160" prop="检验项目" />
|
|
|
+ <el-table-column align="left" label="检验项目" width="260" prop="检验项目" />
|
|
|
+ <el-table-column align="left" label="检验时间" width="160" prop="检验时间" />
|
|
|
<el-table-column align="left" label="检验结果" width="160" prop="检验结果" />
|
|
|
<el-table-column align="left" label="项目备注" width="160" prop="项目备注" />
|
|
|
<el-table-column align="left" label="修改标准" width="160" prop="修改标准" />
|
|
|
</el-table>
|
|
|
<div style="text-align: right; margin-top: 10px; font-size: 14px; color: #606266;">
|
|
|
- 共 {{ zcjyjlTotal }} 条记录
|
|
|
+ 共 {{ zcjyjlTotal }} 次提交<span v-if="zcjyjlCatText">({{ zcjyjlCatText }})</span>
|
|
|
</div>
|
|
|
</el-tab-pane>
|
|
|
|
|
|
@@ -257,6 +259,103 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- 制程检验-本次提交所有项目明细 -->
|
|
|
+ <el-dialog v-model="zcjyjlDetailVisible" title="制程检验记录明细" width="75%" top="10%" append-to-body>
|
|
|
+ <div style="margin-bottom:8px;color:#606266;font-size:13px;">
|
|
|
+ 工单编号:{{ zcjyjlDetailRow?.工单编号 || '-' }} |
|
|
|
+ 流程单号:{{ zcjyjlDetailRow?.流程单号 || '-' }} |
|
|
|
+ 提交时间:{{ zcjyjlDetailRow?.检验时间 || '-' }} |
|
|
|
+ 共 {{ zcjyjlDetailRow?.items?.length || 0 }} 项
|
|
|
+ </div>
|
|
|
+ <el-table :data="zcjyjlDetailRow?.items || []" border size="small" height="55vh"
|
|
|
+ :row-style="{ height: '28px' }" :cell-style="{ padding: '0px 8px' }"
|
|
|
+ :header-row-style="{ height: '26px' }" :header-cell-style="{ padding: '0px 8px' }">
|
|
|
+ <el-table-column align="left" label="检验项目" prop="检验项目" width="160" />
|
|
|
+ <el-table-column align="left" label="检验结果" prop="检验结果" width="140" />
|
|
|
+ <el-table-column align="left" label="项目备注" prop="项目备注" min-width="180" />
|
|
|
+ <el-table-column align="left" label="修改标准" prop="修改标准" min-width="180" />
|
|
|
+ </el-table>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="zcjyjlDetailVisible = false">关闭</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!--制程检验报表弹窗 -->
|
|
|
+ <el-dialog v-model="inspectionReportVisible" width="86%" top="3%" append-to-body
|
|
|
+ @opened="renderInspectionCharts" @closed="disposeInspectionCharts">
|
|
|
+ <template #header>
|
|
|
+ <div style="display:flex;align-items:center;gap:12px;">
|
|
|
+ <span style="font-size:16px;font-weight:600;color:#303133;">制程检验分析报表</span>
|
|
|
+ <el-button type="primary" size="small" @click="onSameProductReport">同类产品报告</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div style="max-height:78vh;overflow-y:auto;padding-right:8px;">
|
|
|
+ <div v-if="inspectionReportError" style="color:red;margin-bottom:10px;">{{ inspectionReportError }}</div>
|
|
|
+ <div v-else-if="inspectionReportData">
|
|
|
+ <div style="margin-bottom:10px;color:#606266;font-size:13px;">
|
|
|
+ 工单号:{{ _GetorderDetail['Gd_gdbh'] }} |
|
|
|
+ 产品名称:{{ _GetorderDetail['Gd_cpmc'] }} |
|
|
|
+ 共 {{ inspectionReportData.row_count }} 行
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 指标卡 -->
|
|
|
+ <div class="ai-kpi">
|
|
|
+ <div class="ai-kpi-item">
|
|
|
+ <div class="ai-kpi-label">提交次数</div>
|
|
|
+ <div class="ai-kpi-value">{{ inspectionKpi.submission }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="ai-kpi-item">
|
|
|
+ <div class="ai-kpi-label">检验项目数</div>
|
|
|
+ <div class="ai-kpi-value">{{ inspectionKpi.itemCount }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="ai-kpi-item">
|
|
|
+ <div class="ai-kpi-label">合格率</div>
|
|
|
+ <div class="ai-kpi-value" :style="{ color: inspectionKpi.passRate >= 98 ? '#67c23a' : '#e6a23c' }">
|
|
|
+ {{ inspectionKpi.passRate }}%
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="ai-kpi-item">
|
|
|
+ <div class="ai-kpi-label">平均提交延迟</div>
|
|
|
+ <div class="ai-kpi-value">{{ inspectionKpi.avgDelay }} 分钟</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 图表区 -->
|
|
|
+ <div ref="inspectionChart1" class="ai-chart" style="height:300px;"></div>
|
|
|
+ <div class="ai-chart-row">
|
|
|
+ <div ref="inspectionChart2" class="ai-chart" style="height:300px;"></div>
|
|
|
+ <div ref="inspectionChart3" class="ai-chart" style="height:300px;"></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 明细表 -->
|
|
|
+ <el-table v-if="inspectionReportData.columns && inspectionReportData.columns.length"
|
|
|
+ :data="inspectionReportData.rows" border size="small" max-height="320"
|
|
|
+ :row-style="{ height: '28px' }" :cell-style="{ padding: '0px 8px' }"
|
|
|
+ :header-row-style="{ height: '26px' }" :header-cell-style="{ padding: '0px 8px' }">
|
|
|
+ <el-table-column v-for="col in inspectionReportData.columns" :key="col.key"
|
|
|
+ align="left" :label="col.label" :prop="col.key" min-width="140" show-overflow-tooltip />
|
|
|
+ </el-table>
|
|
|
+ <div v-if="inspectionReportData.summary" style="margin-top:10px;color:#909399;font-size:12px;">
|
|
|
+ 汇总:{{ inspectionReportData.summary }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="inspectionReportVisible = false">关闭</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!--同类产品检验报告预览弹窗-->
|
|
|
+ <el-dialog v-model="productReportVisible" :title="productReportTitle" width="76%" top="5%" append-to-body>
|
|
|
+ <div v-loading="productReportLoading" style="height:76vh;overflow-y:auto;border:1px solid #ebeef5;">
|
|
|
+ <vue-office-docx v-if="productReportBuffer" :src="productReportBuffer" @error="onProductReportRenderError" />
|
|
|
+ <el-empty v-else-if="!productReportLoading" :description="productReportError || '暂未找到该产品的报告文档'" />
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="productReportVisible = false">关闭</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<PrintPage ref="printPageRef" />
|
|
|
|
|
|
</template>
|
|
|
@@ -289,6 +388,7 @@ import {
|
|
|
getCompanyList
|
|
|
} from '@/api/company'
|
|
|
import PrintPage from '@/view/yunyin/shengchanguanli/components/print.vue'
|
|
|
+import * as echarts from 'echarts'
|
|
|
// 全量引入格式化工具 请按需保留
|
|
|
import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
@@ -301,8 +401,13 @@ import {
|
|
|
StaProcessAnomaly,
|
|
|
StaProcessInspection,
|
|
|
MaterialsBatch,
|
|
|
- PrintingPlateList
|
|
|
+ PrintingPlateList,
|
|
|
+ InspectionAsk,
|
|
|
+ GetInspectionDoc
|
|
|
} from '@/api/mes/job'
|
|
|
+//同类产品报告 word 文档预览
|
|
|
+import VueOfficeDocx from '@vue-office/docx'
|
|
|
+import '@vue-office/docx/lib/index.css'
|
|
|
//获取当前登录用户信息
|
|
|
import { useUserStore } from '@/pinia/modules/user'
|
|
|
const userStore = useUserStore()
|
|
|
@@ -311,7 +416,7 @@ const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
|
|
|
defineOptions({
|
|
|
name: 'Onderstatus'
|
|
|
})
|
|
|
-
|
|
|
+console.log(userStore.userInfo.userName)
|
|
|
//进入页面默认光标加载
|
|
|
setTimeout(() => {
|
|
|
const inputElement = document.getElementById('searchInfo');
|
|
|
@@ -682,6 +787,16 @@ const _StaProcessList = async () => {
|
|
|
//制程检验记录
|
|
|
const zcjyjltableData = reactive([])
|
|
|
const zcjyjlTotal = ref(0) // 添加总数变量
|
|
|
+const zcjyjlCatText = ref('') // 各类别提交次数文案
|
|
|
+const zcjyjlDetailVisible = ref(false)
|
|
|
+const zcjyjlDetailRow = ref(null)
|
|
|
+
|
|
|
+// 双击行 → 弹窗显示本次提交所有检验项目
|
|
|
+const zcjyjlSelectClick = (row) => {
|
|
|
+ if (!row) return
|
|
|
+ zcjyjlDetailRow.value = row
|
|
|
+ zcjyjlDetailVisible.value = true
|
|
|
+}
|
|
|
|
|
|
const _StaProcessInspection = async () => {
|
|
|
try {
|
|
|
@@ -690,19 +805,23 @@ const _StaProcessInspection = async () => {
|
|
|
|
|
|
if (StaProcessInspectiondata.code === 0) {
|
|
|
const tableData = StaProcessInspectiondata.data?.data || []
|
|
|
- const total = StaProcessInspectiondata.data?.total || 0
|
|
|
+ const cats = StaProcessInspectiondata.data?.categories || []
|
|
|
+ const catTotal = StaProcessInspectiondata.data?.catTotal || 0
|
|
|
zcjyjltableData.splice(0, zcjyjltableData.length, ...tableData)
|
|
|
- zcjyjlTotal.value = total
|
|
|
- console.log('制程检验加载数据:', tableData.length, '条,总数:', total)
|
|
|
+ zcjyjlTotal.value = catTotal
|
|
|
+ zcjyjlCatText.value = cats.map(c => `${c.category}(${c.count})次`).join('、')
|
|
|
+ console.log('制程检验加载数据:', tableData.length, '条,分类统计:', zcjyjlCatText.value)
|
|
|
} else {
|
|
|
zcjyjltableData.splice(0, zcjyjltableData.length, ...[])
|
|
|
zcjyjlTotal.value = 0
|
|
|
+ zcjyjlCatText.value = ''
|
|
|
console.warn('制程检验接口返回错误:', StaProcessInspectiondata.msg)
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('获取制程检验数据失败:', error)
|
|
|
zcjyjltableData.splice(0, zcjyjltableData.length, ...[])
|
|
|
zcjyjlTotal.value = 0
|
|
|
+ zcjyjlCatText.value = ''
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -841,12 +960,334 @@ const pd_gdprintonClick = () => {
|
|
|
printPageRef.value.open(_GetorderDetail.value['Gd_gdbh'])
|
|
|
}
|
|
|
|
|
|
+// ========== AI 制程检验报表(调后端 Agent.php 代理接口) ==========
|
|
|
+
|
|
|
+const inspectionLoading = ref(false)
|
|
|
+const inspectionReportVisible = ref(false)
|
|
|
+const inspectionReportData = ref(null)
|
|
|
+const inspectionReportError = ref('')
|
|
|
+const inspectionChart1 = ref(null)
|
|
|
+const inspectionChart2 = ref(null)
|
|
|
+const inspectionChart3 = ref(null)
|
|
|
+let inspectionChartInstances = []
|
|
|
+const inspectionKpi = ref({ submission: 0, itemCount: 0, passRate: '0.00', avgDelay: '0' })
|
|
|
+
|
|
|
+// ========== 同类产品检验报告(按产品名称查找宝塔 uploads/Inspection 下的文档) ==========
|
|
|
+
|
|
|
+const productReportVisible = ref(false)
|
|
|
+const productReportLoading = ref(false)
|
|
|
+const productReportTitle = ref('同类产品报告')
|
|
|
+const productReportBuffer = ref(null)
|
|
|
+const productReportError = ref('')
|
|
|
+
|
|
|
+// base64 -> ArrayBuffer,供 vue-office 直接渲染
|
|
|
+const base64ToArrayBuffer = (b64) => {
|
|
|
+ const bin = atob(b64)
|
|
|
+ const len = bin.length
|
|
|
+ const bytes = new Uint8Array(len)
|
|
|
+ for (let i = 0; i < len; i++) {
|
|
|
+ bytes[i] = bin.charCodeAt(i)
|
|
|
+ }
|
|
|
+ return bytes.buffer
|
|
|
+}
|
|
|
+
|
|
|
+const onProductReportRenderError = () => {
|
|
|
+ productReportBuffer.value = null
|
|
|
+ productReportError.value = '文档渲染失败,可尝试转换为 PDF 后再预览'
|
|
|
+}
|
|
|
+
|
|
|
+const onSameProductReport = async () => {
|
|
|
+ const cpmc = _GetorderDetail.value?.['Gd_cpmc']
|
|
|
+ if (!cpmc) {
|
|
|
+ ElMessage({ type: 'warning', message: '未获取到产品名称' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ productReportTitle.value = '同类产品报告 - ' + cpmc
|
|
|
+ productReportBuffer.value = null
|
|
|
+ productReportError.value = ''
|
|
|
+ productReportVisible.value = true
|
|
|
+ productReportLoading.value = true
|
|
|
+ try {
|
|
|
+ const resp = await GetInspectionDoc({ cpmc })
|
|
|
+ const d = resp?.data ?? resp
|
|
|
+ if (d && d.found && d.content) {
|
|
|
+ productReportBuffer.value = base64ToArrayBuffer(d.content)
|
|
|
+ } else {
|
|
|
+ productReportError.value = d?.msg || '未找到该产品的报告文档'
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ productReportError.value = '请求失败:' + (e?.message || '')
|
|
|
+ } finally {
|
|
|
+ productReportLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const numVal = (v) => {
|
|
|
+ const n = Number(v)
|
|
|
+ return isNaN(n) ? 0 : n
|
|
|
+}
|
|
|
+
|
|
|
+// 从 columns 中按候选 key / label 关键字定位字段
|
|
|
+const pickField = (cols, keys, labels) => {
|
|
|
+ const c = cols.find(x => keys.includes(x.key)) ||
|
|
|
+ cols.find(x => labels.some(l => String(x.label || '').includes(l)))
|
|
|
+ return c ? c.key : ''
|
|
|
+}
|
|
|
+
|
|
|
+const buildInspectionData = () => {
|
|
|
+ const d = inspectionReportData.value
|
|
|
+ if (!d || !d.rows || !d.rows.length) return null
|
|
|
+ const cols = d.columns || []
|
|
|
+ const rows = d.rows
|
|
|
+
|
|
|
+ const dateKey = pickField(cols, ['submit_date', 'date'], ['日期'])
|
|
|
+ const catKey = pickField(cols, ['category'], ['类别'])
|
|
|
+ const subKey = pickField(cols, ['submission_count'], ['提交次数'])
|
|
|
+ const itemKey = pickField(cols, ['item_count'], ['检验项目数', '项目数'])
|
|
|
+ const passKey = pickField(cols, ['pass_count'], ['合格数'])
|
|
|
+ const failKey = pickField(cols, ['fail_count'], ['不合格数'])
|
|
|
+ const uncheckedKey = pickField(cols, ['unchecked_count'], ['未检测'])
|
|
|
+ const rateKey = pickField(cols, ['pass_rate'], ['合格率'])
|
|
|
+ const delayKey = pickField(cols, ['avg_delay_minutes'], ['延迟'])
|
|
|
+
|
|
|
+ const dateMap = new Map()
|
|
|
+ const catMap = new Map()
|
|
|
+ let totalSub = 0, totalItem = 0, totalPass = 0, totalFail = 0, delaySum = 0, delayCnt = 0
|
|
|
+
|
|
|
+ rows.forEach(r => {
|
|
|
+ const date = dateKey ? String(r[dateKey] ?? '') : '-'
|
|
|
+ const cat = catKey ? String(r[catKey] ?? '未分类') : '全部'
|
|
|
+ const sub = subKey ? numVal(r[subKey]) : 1
|
|
|
+ const item = itemKey ? numVal(r[itemKey]) : 0
|
|
|
+ const pass = passKey ? numVal(r[passKey]) : 0
|
|
|
+ const fail = failKey ? numVal(r[failKey]) : 0
|
|
|
+ const unchecked = uncheckedKey ? numVal(r[uncheckedKey]) : 0
|
|
|
+ const delay = delayKey ? numVal(r[delayKey]) : 0
|
|
|
+
|
|
|
+ if (!dateMap.has(date)) {
|
|
|
+ dateMap.set(date, { date, sub: 0, item: 0, pass: 0, fail: 0, unchecked: 0 })
|
|
|
+ }
|
|
|
+ const dm = dateMap.get(date)
|
|
|
+ dm.sub += sub
|
|
|
+ dm.item += item
|
|
|
+ dm.pass += pass
|
|
|
+ dm.fail += fail
|
|
|
+ dm.unchecked += unchecked
|
|
|
+
|
|
|
+ catMap.set(cat, (catMap.get(cat) || 0) + sub)
|
|
|
+
|
|
|
+ totalSub += sub
|
|
|
+ totalItem += item
|
|
|
+ totalPass += pass
|
|
|
+ totalFail += fail
|
|
|
+ if (delayKey) { delaySum += delay; delayCnt += 1 }
|
|
|
+ })
|
|
|
+
|
|
|
+ const dates = Array.from(dateMap.keys()).sort()
|
|
|
+ const list = dates.map(k => dateMap.get(k))
|
|
|
+ // 合格率:优先按 合格数/(合格数+不合格数) 计算,无数据时退回 0
|
|
|
+ list.forEach(x => {
|
|
|
+ const judged = x.pass + x.fail
|
|
|
+ x.rate = judged > 0 ? Number((x.pass / judged * 100).toFixed(2)) : 0
|
|
|
+ })
|
|
|
+
|
|
|
+ const hasResult = !!(passKey || failKey || uncheckedKey)
|
|
|
+ const totalRate = (totalPass + totalFail) > 0 ? (totalPass / (totalPass + totalFail) * 100).toFixed(2) : '0.00'
|
|
|
+
|
|
|
+ inspectionKpi.value = {
|
|
|
+ submission: totalSub,
|
|
|
+ itemCount: totalItem,
|
|
|
+ passRate: totalRate,
|
|
|
+ avgDelay: delayCnt ? (delaySum / delayCnt).toFixed(1) : '0'
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ dates,
|
|
|
+ list,
|
|
|
+ catArr: Array.from(catMap.entries()).map(([name, value]) => ({ name, value })),
|
|
|
+ hasResult,
|
|
|
+ hasRate: !!rateKey || !!(passKey || failKey)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const disposeInspectionCharts = () => {
|
|
|
+ window.removeEventListener('resize', handleInspectionResize)
|
|
|
+ inspectionChartInstances.forEach(c => { try { c.dispose() } catch (e) { /* ignore */ } })
|
|
|
+ inspectionChartInstances = []
|
|
|
+}
|
|
|
+
|
|
|
+const handleInspectionResize = () => {
|
|
|
+ inspectionChartInstances.forEach(c => { try { c.resize() } catch (e) { /* ignore */ } })
|
|
|
+}
|
|
|
+
|
|
|
+const renderInspectionCharts = () => {
|
|
|
+ nextTick(() => {
|
|
|
+ const data = buildInspectionData()
|
|
|
+ if (!data) return
|
|
|
+ disposeInspectionCharts()
|
|
|
+ const { dates, list, catArr, hasResult } = data
|
|
|
+
|
|
|
+ // 图1:提交次数(柱)+ 合格率(折线)
|
|
|
+ if (inspectionChart1.value) {
|
|
|
+ const c1 = echarts.init(inspectionChart1.value)
|
|
|
+ c1.setOption({
|
|
|
+ title: { text: '每日提交次数与合格率', left: 'center', textStyle: { fontSize: 14 } },
|
|
|
+ tooltip: { trigger: 'axis' },
|
|
|
+ legend: { data: ['提交次数', '合格率'], top: 26 },
|
|
|
+ grid: { left: 50, right: 55, top: 70, bottom: 40 },
|
|
|
+ xAxis: { type: 'category', data: dates, axisLabel: { rotate: dates.length > 8 ? 40 : 0 } },
|
|
|
+ yAxis: [
|
|
|
+ { type: 'value', name: '提交次数' },
|
|
|
+ { type: 'value', name: '合格率(%)', min: 0, max: 100 }
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ { name: '提交次数', type: 'bar', barMaxWidth: 36, itemStyle: { color: '#409eff' }, data: list.map(x => x.sub) },
|
|
|
+ {
|
|
|
+ name: '合格率', type: 'line', yAxisIndex: 1, smooth: true,
|
|
|
+ itemStyle: { color: '#67c23a' }, data: list.map(x => x.rate),
|
|
|
+ label: { show: true, formatter: '{c}%', fontSize: 10 }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ inspectionChartInstances.push(c1)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 图2:检验类别占比
|
|
|
+ if (inspectionChart2.value) {
|
|
|
+ const c2 = echarts.init(inspectionChart2.value)
|
|
|
+ c2.setOption({
|
|
|
+ title: { text: '检验类别占比', left: 'center', textStyle: { fontSize: 14 } },
|
|
|
+ tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
|
|
+ legend: { bottom: 0, type: 'scroll' },
|
|
|
+ series: [{
|
|
|
+ type: 'pie', radius: ['38%', '62%'], center: ['50%', '48%'],
|
|
|
+ avoidLabelOverlap: true,
|
|
|
+ label: { formatter: '{b}\n{d}%', fontSize: 11 },
|
|
|
+ data: catArr
|
|
|
+ }]
|
|
|
+ })
|
|
|
+ inspectionChartInstances.push(c2)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 图3:判定结果分布 / 项目数
|
|
|
+ if (inspectionChart3.value) {
|
|
|
+ const c3 = echarts.init(inspectionChart3.value)
|
|
|
+ if (hasResult) {
|
|
|
+ c3.setOption({
|
|
|
+ title: { text: '每日判定结果分布', left: 'center', textStyle: { fontSize: 14 } },
|
|
|
+ tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
|
|
+ legend: { data: ['合格', '不合格', '未检测'], top: 26 },
|
|
|
+ grid: { left: 50, right: 20, top: 70, bottom: 40 },
|
|
|
+ xAxis: { type: 'category', data: dates, axisLabel: { rotate: dates.length > 8 ? 40 : 0 } },
|
|
|
+ yAxis: { type: 'value' },
|
|
|
+ series: [
|
|
|
+ { name: '合格', type: 'bar', stack: 'total', itemStyle: { color: '#67c23a' }, data: list.map(x => x.pass) },
|
|
|
+ { name: '不合格', type: 'bar', stack: 'total', itemStyle: { color: '#f56c6c' }, data: list.map(x => x.fail) },
|
|
|
+ { name: '未检测', type: 'bar', stack: 'total', itemStyle: { color: '#e6a23c' }, data: list.map(x => x.unchecked) }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ c3.setOption({
|
|
|
+ title: { text: '每日检验项目数', left: 'center', textStyle: { fontSize: 14 } },
|
|
|
+ tooltip: { trigger: 'axis' },
|
|
|
+ grid: { left: 50, right: 20, top: 60, bottom: 40 },
|
|
|
+ xAxis: { type: 'category', data: dates, axisLabel: { rotate: dates.length > 8 ? 40 : 0 } },
|
|
|
+ yAxis: { type: 'value' },
|
|
|
+ series: [{ name: '检验项目数', type: 'bar', barMaxWidth: 36, itemStyle: { color: '#909399' }, data: list.map(x => x.item) }]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ inspectionChartInstances.push(c3)
|
|
|
+ }
|
|
|
+
|
|
|
+ window.addEventListener('resize', handleInspectionResize)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 数据返回后(弹窗已打开)再渲染图表
|
|
|
+watch(inspectionReportData, (val) => {
|
|
|
+ if (val && inspectionReportVisible.value) {
|
|
|
+ renderInspectionCharts()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const onInspectionReport = async () => {
|
|
|
+ const workOrder = _GetorderDetail.value?.['Gd_gdbh']
|
|
|
+ if (!workOrder) {
|
|
|
+ ElMessage({ type: 'warning', message: '未获取到工单编号' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ inspectionLoading.value = true
|
|
|
+ inspectionReportError.value = ''
|
|
|
+ inspectionReportData.value = null
|
|
|
+ inspectionReportVisible.value = true
|
|
|
+ try {
|
|
|
+ const resp = await InspectionAsk({
|
|
|
+ skill_id: 'inspection_analysis',
|
|
|
+ question: workOrder,
|
|
|
+ mode: 'summary',
|
|
|
+ user_id: userStore.userInfo.userName
|
|
|
+ })
|
|
|
+ // request.js 拦截器 code=0 时返回 response.data,即 {code,msg,data}
|
|
|
+ const d = resp?.data ?? resp
|
|
|
+ if (d && d.ok) {
|
|
|
+ inspectionReportData.value = d
|
|
|
+ ElMessage({ type: 'success', message: `获取成功:${d.row_count} 行` })
|
|
|
+ } else {
|
|
|
+ inspectionReportError.value = d?.detail || d?.msg || (typeof d === 'string' ? d : JSON.stringify(d))
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ const msg = e?.response?.data?.detail || e?.response?.data?.msg || e.message
|
|
|
+ inspectionReportError.value = '请求失败:' + msg
|
|
|
+ } finally {
|
|
|
+ inspectionLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
+ /* 制程检验分析报表 */
|
|
|
+ .ai-kpi {
|
|
|
+ display: flex;
|
|
|
+ gap: 12px;
|
|
|
+ margin-bottom: 12px;
|
|
|
+ }
|
|
|
+ .ai-kpi-item {
|
|
|
+ flex: 1;
|
|
|
+ padding: 10px 14px;
|
|
|
+ border: 1px solid #ebeef5;
|
|
|
+ border-radius: 6px;
|
|
|
+ background: #fafafa;
|
|
|
+ }
|
|
|
+ .ai-kpi-label {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+ margin-bottom: 6px;
|
|
|
+ }
|
|
|
+ .ai-kpi-value {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #303133;
|
|
|
+ }
|
|
|
+ .ai-chart {
|
|
|
+ width: 100%;
|
|
|
+ border: 1px solid #ebeef5;
|
|
|
+ border-radius: 6px;
|
|
|
+ background: #fff;
|
|
|
+ }
|
|
|
+ .ai-chart-row {
|
|
|
+ display: flex;
|
|
|
+ gap: 12px;
|
|
|
+ margin: 12px 0;
|
|
|
+ }
|
|
|
+ .ai-chart-row .ai-chart {
|
|
|
+ flex: 1;
|
|
|
+ min-width: 0;
|
|
|
+ }
|
|
|
+
|
|
|
:deep(.plan-usage-low div) {
|
|
|
color: red !important;
|
|
|
}
|