zck 5 hari lalu
induk
melakukan
462c87578b
29 mengubah file dengan 5292 tambahan dan 347 penghapusan
  1. 153 0
      src/api/DecisionSupport/decision.js
  2. 8 0
      src/api/jixiaoguanli/baogong.js
  3. 16 0
      src/api/jixiaoguanli/jitairibaobiao.js
  4. 45 0
      src/api/mes/job.js
  5. 27 0
      src/api/mes_api_gty/orderAccounting.js
  6. 8 0
      src/api/yunyin/yunying.js
  7. 369 0
      src/view/DecisionSupport/AnnualPrintingEfficiencyStatistics.vue
  8. 285 0
      src/view/DecisionSupport/CompletionOrderProductionCycleStatistics.vue
  9. 505 0
      src/view/DecisionSupport/CustomerQualityStatistics.vue
  10. 285 0
      src/view/DecisionSupport/EquipmentWeekDataStatistics.vue
  11. 77 48
      src/view/DecisionSupport/MonthProductOutputRate.vue
  12. 26 34
      src/view/DecisionSupport/Monthlyplatescrap.vue
  13. 38 15
      src/view/DecisionSupport/ProductOutputRate.vue
  14. 333 0
      src/view/DecisionSupport/YearManualinspectionStatistics.vue
  15. 290 0
      src/view/DecisionSupport/Yearcprctj.vue
  16. 308 0
      src/view/DecisionSupport/cprctj.vue
  17. 86 63
      src/view/DecisionSupport/productioncents/index.vue
  18. 219 2
      src/view/performance/12-orderAccounting/componets/xzgdtl.vue
  19. 1 1
      src/view/performance/12-orderAccounting/index.vue
  20. 83 17
      src/view/performance/chejianbaogong.vue
  21. 133 23
      src/view/quality/Customerfeedback.vue
  22. 250 53
      src/view/quality/ManagementQuality.vue
  23. 253 46
      src/view/quality/Productquality.vue
  24. 31 2
      src/view/quality/management.vue
  25. 450 9
      src/view/quality/orderstatus.vue
  26. 92 16
      src/view/yunyin/chanpinziliao/chanpinziliao.vue
  27. 520 0
      src/view/yunyin/shengchanguanli/components/gongyiziliao.vue
  28. 13 0
      src/view/yunyin/shengchanguanli/gongdanshengchan.vue
  29. 388 18
      src/view/yunyin/shengchanguanli/shebeiyunxing.vue

+ 153 - 0
src/api/DecisionSupport/decision.js

@@ -46,4 +46,157 @@ export const ChromaticityNumber= (params) => {
         method: 'get',
         params
     })
+}
+
+//成品入仓统计->左侧菜单(年 -> 年月)
+export const CprctjLeft= (params) => {
+    return service({
+        url: '/mes_server/decision/CprctjLeft',
+        method: 'get',
+        params
+    })
+}
+
+//成品入仓统计->上方表格(按日期汇总)
+export const CprctjList_hz= (params) => {
+    return service({
+        url: '/mes_server/decision/CprctjList_hz',
+        method: 'get',
+        params
+    })
+}
+
+//成品入仓统计->下方表格(工单+印件明细)
+export const CprctjList_mx= (params) => {
+    return service({
+        url: '/mes_server/decision/CprctjList_mx',
+        method: 'get',
+        params
+    })
+}
+
+//年度成品入仓统计->左侧菜单(年 -> 客户)
+export const YearcprctjLeft= (params) => {
+    return service({
+        url: '/mes_server/decision/YearcprctjLeft',
+        method: 'get',
+        params
+    })
+}
+
+//年度成品入仓统计->右侧表格
+export const YearcprctjList= (params) => {
+    return service({
+        url: '/mes_server/decision/YearcprctjList',
+        method: 'get',
+        params
+    })
+}
+
+//客诉质量缺陷统计A->左侧菜单(年 -> 缺陷关键字)
+export const KhtjLeftA= (params) => {
+    return service({
+        url: '/mes_server/decision/KhtjLeftA',
+        method: 'get',
+        params
+    })
+}
+
+//客诉质量缺陷统计A->明细表格
+export const KhtjListA= (params) => {
+    return service({
+        url: '/mes_server/decision/KhtjListA',
+        method: 'get',
+        params
+    })
+}
+
+//客诉质量缺陷统计B->左侧菜单(年 -> 客户)
+export const KhtjLeftB= (params) => {
+    return service({
+        url: '/mes_server/decision/KhtjLeftB',
+        method: 'get',
+        params
+    })
+}
+
+//客诉质量缺陷统计B->月度汇总+明细表格
+export const KhtjListB= (params) => {
+    return service({
+        url: '/mes_server/decision/KhtjListB',
+        method: 'get',
+        params
+    })
+}
+
+//年度打样效率统计->左侧菜单(年 -> 年月)
+export const DyxlLeft= (params) => {
+    return service({
+        url: '/mes_server/decision/DyxlLeft',
+        method: 'get',
+        params
+    })
+}
+
+//年度打样效率统计->汇总+明细表格
+export const DyxlList= (params) => {
+    return service({
+        url: '/mes_server/decision/DyxlList',
+        method: 'get',
+        params
+    })
+}
+
+//年度手工检验统计->左侧菜单(年 -> 客户)
+export const YearSgyjLeft= (params) => {
+    return service({
+        url: '/mes_server/decision/YearSgyjLeft',
+        method: 'get',
+        params
+    })
+}
+
+//年度手工检验统计->上方汇总+下方工单明细
+export const YearSgyjList= (params) => {
+    return service({
+        url: '/mes_server/decision/YearSgyjList',
+        method: 'get',
+        params
+    })
+}
+
+//设备周数据统计->左侧菜单(车间 -> 机台)
+export const EqwdtLeft= (params) => {
+    return service({
+        url: '/mes_server/decision/EqwdtLeft',
+        method: 'get',
+        params
+    })
+}
+
+//设备周数据统计->汇总+明细
+export const EqwdtList= (params) => {
+    return service({
+        url: '/mes_server/decision/EqwdtList',
+        method: 'get',
+        params
+    })
+}
+
+//完工工单生产周期统计->左侧菜单(年月 -> 客户)
+export const CopsTab= (params) => {
+    return service({
+        url: '/mes_server/decision/CopsTab',
+        method: 'get',
+        params
+    })
+}
+
+//完工工单生产周期统计->列表
+export const CopsList= (params) => {
+    return service({
+        url: '/mes_server/decision/CopsList',
+        method: 'get',
+        params
+    })
 }

+ 8 - 0
src/api/jixiaoguanli/baogong.js

@@ -56,6 +56,14 @@ export const RemodelDetail = (params) => {
     params
   })
 }
+// 换型清场-根据机台获取设备_产量采集最新两个工单
+export const RemodelLastOrders = (params) => {
+  return service({
+    url: '/mes_server/Facility/RemodelLastOrders',
+    method: 'get',
+    params
+  })
+}
 export const ChanliangDel = (params) => {
   return service({
     url: '/mes_server/facility/ChanliangDel',

+ 16 - 0
src/api/jixiaoguanli/jitairibaobiao.js

@@ -784,6 +784,22 @@ export const MachineChanliangDetailEdit = (data) => {
     data
   })
 }
+//难度系数校验-左侧车间机台树
+export const getCoefTab = (params) => {
+  return service({
+    url:'/mes_server/Facility/getCoefTab',
+    method: 'get',
+    params
+  })
+}
+//难度系数校验-按机台查询产量数据
+export const getCoefList = (params) => {
+  return service({
+    url:'/mes_server/Facility/getCoefList',
+    method: 'get',
+    params
+  })
+}
 //每日上报产量工价
 export const CoefficientEdit = (data) => {
   return service({

+ 45 - 0
src/api/mes/job.js

@@ -388,6 +388,24 @@ export const PrintingPlateList = (params) => {
   })
 }
 
+//AI 制程检验分析报表(后端 Agent.php 代理 AI 平台)
+export const InspectionAsk = (data) => {
+  return service({
+    url: '/mes_server/agent/inspectionAsk',
+    method: 'post',
+    data
+  })
+}
+
+//同类产品检验报告(后端 Agent.php 查找 uploads/Inspection 下的文档)
+export const GetInspectionDoc = (params) => {
+  return service({
+    url: '/mes_server/agent/getInspectionDoc',
+    method: 'get',
+    params
+  })
+}
+
 
 /*
 	工序大废品统计
@@ -521,6 +539,33 @@ export const Productmonthlist = (params) => {
   })
 }
 
+//产品月度投入产出率统计->左侧菜单
+export const Productmonthleft = (params) => {
+  return service({
+    url: '/mes_server/Achievementatestatistics/left_Productmonth',
+    method: 'get',
+    params
+  })
+}
+
+//产品月度投入产出率统计->数据汇总表
+export const Productmonthlist_hz = (params) => {
+  return service({
+    url: '/mes_server/Achievementatestatistics/list_Productmonth_hz',
+    method: 'get',
+    params
+  })
+}
+
+//产品月度投入产出率统计->数据明细表
+export const Productmonthlist_mx = (params) => {
+  return service({
+    url: '/mes_server/Achievementatestatistics/list_Productmonth_mx',
+    method: 'get',
+    params
+  })
+}
+
 //年度质检废品率统计左侧菜单
 export const QIGetTab = (params) => {
   return service({

+ 27 - 0
src/api/mes_api_gty/orderAccounting.js

@@ -111,3 +111,30 @@ export const EmployeeDataCollect = (data) => {
 // 7核检废品分布(工单核检单维护3.1)
 // 8流程单查询(工单核检单维护5.1,5.2)
 // 9工单质检废品统计(工单核检单维护8)
+
+// 产品质量改善措施管理 —— 工序质量缺陷明细
+export const getOrderQuality = (params) => {
+  return service({
+    url: '/mes_server/order_super_loss/getOrderQuality',
+    method: 'get',
+    params
+  })
+}
+
+// 产品品质统计 —— 左侧树(年 → 月 → 厂商)
+export const getProductQualityTab = (params) => {
+  return service({
+    url: '/mes_server/order_super_loss/getProductQualityTab',
+    method: 'get',
+    params
+  })
+}
+
+// 产品品质统计 —— 按产品合计 / 单产品工单明细
+export const getProductQualityList = (params) => {
+  return service({
+    url: '/mes_server/order_super_loss/getProductQualityList',
+    method: 'get',
+    params
+  })
+}

+ 8 - 0
src/api/yunyin/yunying.js

@@ -83,6 +83,14 @@ export const editGy = (data) => {
         data
     })
 }
+//5.1预览修改工艺参数(仅返回影响的工单列表)
+export const editGyPreview = (data) => {
+    return service({
+        url: '/mes_server/product/editGyPreview',
+        method: 'post',
+        data
+    })
+}
 //6.修改产品基本资料
 export const editProduct = (data) => {
     return service({

+ 369 - 0
src/view/DecisionSupport/AnnualPrintingEfficiencyStatistics.vue

@@ -0,0 +1,369 @@
+<template>
+  <div>
+    <layout>
+      <layout-header>
+        <div class="">
+          <el-form class="demo-form-inline">
+            <el-form-item>
+              <el-button type="primary" class="bt" icon="download" @click="exportSummary">导出汇总</el-button>
+              <el-button type="primary" class="bt" icon="download" @click="exportDetail">导出明细</el-button>
+            </el-form-item>
+          </el-form>
+        </div>
+      </layout-header>
+
+      <layout>
+        <!-- 左侧树:年 -> 年月 -->
+        <layout-sider :resize-directions="['right']" :width="230" style="margin-right: 10px;">
+          <div class="JKWTree-tree">
+            <h3>年度打样效率统计</h3>
+            <el-tree ref="treeRef" :data="treeData" :props="defaultProps" node-key="key"
+                     :default-expanded-keys="expandedKeys"
+                     highlight-current @node-click="handleNodeClick">
+            </el-tree>
+          </div>
+        </layout-sider>
+
+        <!-- 右侧区域:上方汇总、下方明细 -->
+        <layout-content>
+          <el-main>
+            <div class="gva-table-box">
+              <el-table id="dyhztable" ref="summaryTableRef" style="width: 100%;height: 32vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="summaryData" border size="small"
+                        :span-method="spanMethod" :row-class-name="rowClassName"
+                        highlight-current-row :show-overflow-tooltip="true"
+                        @row-click="handleSummaryRowClick">
+                <el-table-column align="center" label="年月" prop="年月" width="80" />
+                <el-table-column align="center" label="客户编号" prop="客户编号" width="90" />
+                <el-table-column align="center" label="客户名称" prop="客户名称" width="140" />
+                <el-table-column align="center" label="工单编号" prop="工单编号" width="95" />
+                <el-table-column align="center" label="成品名称" prop="成品名称" min-width="180" />
+                <el-table-column v-for="item in workHourCols" :key="item.prop" align="center"
+                                 :label="item.label" :prop="item.prop" width="120" />
+              </el-table>
+            </div>
+
+            <div class="gva-table-box" style="margin-top: 8px;">
+              <el-table id="dymxtable" ref="detailTableRef" style="width: 100%;height: 40vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="detailData" border size="small"
+                        highlight-current-row :show-overflow-tooltip="true">
+                <el-table-column align="center" label="年月" prop="年月" width="80" />
+                <el-table-column align="center" label="客户编号" prop="客户编号" width="90" />
+                <el-table-column align="center" label="客户名称" prop="客户名称" width="140" />
+                <el-table-column align="center" label="工单编号" prop="工单编号" width="95" />
+                <el-table-column align="center" label="成品名称" prop="成品名称" min-width="180" />
+                <el-table-column align="center" label="印件及工序" prop="印件及工序" width="110" />
+                <el-table-column v-for="item in workHourCols" :key="item.prop" align="center"
+                                 :label="item.label" :prop="item.prop" width="120" />
+              </el-table>
+            </div>
+          </el-main>
+        </layout-content>
+      </layout>
+    </layout>
+  </div>
+</template>
+
+<script setup>
+import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue';
+
+import { ref, nextTick } from 'vue'
+import { ElMessage } from "element-plus";
+import * as XLSX from 'xlsx'
+import { DyxlLeft, DyxlList } from "@/api/DecisionSupport/decision.js"
+
+defineOptions({name: 'AnnualPrintingEfficiencyStatistics'})
+
+const treeRef = ref(null)
+const summaryTableRef = ref(null)
+const detailTableRef = ref(null)
+const treeData = ref([])
+const expandedKeys = ref([])
+const defaultProps = {
+  children: 'children',
+  label: 'label'
+}
+
+// 当前选中的日期:4位为整年,6位为年月
+const currentDate = ref('')
+
+const summaryData = ref([])
+const detailData = ref([])
+// 当前条件下的全部明细,点击上方汇总行后按工单筛选显示到下方表格
+const allDetailData = ref([])
+// 防止快速切换时旧请求覆盖新数据
+let requestId = 0
+
+// 工序分类及工时列
+const categories = ['胶印', '凹印', '单凹', '喷码', '丝印', '烫金', '模切']
+const workHourCols = categories.flatMap(category => ([
+  { label: `${category}计划工时`, prop: `${category}计划工时` },
+  { label: `${category}实际工时`, prop: `${category}实际工时` },
+]))
+
+// =========== 左侧树:年 -> 年月 ===========
+const getTreeData = async () => {
+  try {
+    const res = await DyxlLeft()
+    if (res.code === 0 && Array.isArray(res.data)) {
+      treeData.value = res.data.map(yearItem => ({
+        label: String(yearItem.年份),
+        key: `Y${yearItem.年份}`,
+        date: String(yearItem.年份),
+        children: (yearItem.月份 || []).map(monthItem => ({
+          label: String(monthItem),
+          key: `Y${yearItem.年份}-M${monthItem}`,
+          date: String(monthItem)
+        }))
+      }))
+
+      // 只加载树数据;不自动展开/聚焦/查询,等用户点击节点后再加载
+      if (treeData.value.length) {
+        const firstYear = treeData.value[0]
+        expandedKeys.value = [firstYear.key]
+      }
+    } else {
+      console.error('获取数据失败:', res.msg)
+    }
+  } catch (error) {
+    console.error('请求出错:', error)
+  }
+}
+getTreeData()
+
+// 点击年份查询全年,点击月份查询该月
+const handleNodeClick = (nodeData) => {
+  if (!nodeData || !nodeData.date) {
+    return
+  }
+  currentDate.value = nodeData.date
+  fetchData()
+}
+
+const fetchData = async () => {
+  if (!currentDate.value) {
+    ElMessage.warning('请先在左侧选择年月')
+    return
+  }
+  const id = ++requestId
+  summaryData.value = []
+  detailData.value = []
+  allDetailData.value = []
+  try {
+    const res = await DyxlList({ date: currentDate.value })
+    if (id !== requestId) {
+      return
+    }
+    const data = res.data || {}
+    summaryData.value = data.summary || []
+    allDetailData.value = data.detail || []
+  } catch (error) {
+    if (id !== requestId) {
+      return
+    }
+    console.error('请求出错:', error)
+    summaryData.value = []
+    allDetailData.value = []
+  }
+}
+
+// 点击上方汇总行,下方按工单显示对应明细(未点击时下方为空)
+const handleSummaryRowClick = (row) => {
+  if (!row || row.isTotal || !row.工单编号) {
+    detailData.value = []
+    return
+  }
+  const gdbh = String(row.工单编号).trim()
+  const yearMonth = String(row.年月 || '').trim()
+  detailData.value = allDetailData.value.filter(item => {
+    if (String(item.工单编号 || '').trim() !== gdbh) {
+      return false
+    }
+    return yearMonth === '' || String(item.年月 || '').trim() === yearMonth
+  })
+}
+
+// 合计行合并前5列,并加黄色背景
+const spanMethod = ({ row, columnIndex }) => {
+  if (!row.isTotal) {
+    return
+  }
+  if (columnIndex === 0) {
+    return { rowspan: 1, colspan: 5 }
+  }
+  if (columnIndex >= 1 && columnIndex <= 4) {
+    return { rowspan: 0, colspan: 0 }
+  }
+}
+
+const rowClassName = ({ row }) => {
+  if (!row.isTotal) {
+    return ''
+  }
+  // 为多个合计行分别加 class:倒数第 N 个合计行 -> total-row-sticky-N
+  // bottom 偏移 = (N-1) * 行高(25px)
+  const totalRows = summaryData.value.filter(r => r.isTotal)
+  const totalCount = totalRows.length
+  const idx = totalRows.findIndex(r => r === row)
+  const offset = totalCount - idx
+  return `total-row total-row-sticky-${offset}`
+}
+
+// 将指定列范围内的数值字符串转换为数字
+const convertNumericCells = (worksheet, startCol, endCol) => {
+  if (!worksheet || !worksheet['!ref']) {
+    return
+  }
+  const range = XLSX.utils.decode_range(worksheet['!ref'])
+  for (let r = range.s.r + 1; r <= range.e.r; r++) {
+    for (let c = startCol; c <= endCol; c++) {
+      const cell = worksheet[XLSX.utils.encode_cell({ r, c })]
+      if (cell && cell.v !== '' && cell.v !== null && cell.v !== undefined) {
+        const numValue = Number(cell.v)
+        if (!isNaN(numValue)) {
+          cell.t = 'n'
+          cell.v = numValue
+        }
+      }
+    }
+  }
+}
+
+// 仅导出上方汇总表
+const exportSummary = () => {
+  if (!summaryData.value.length) {
+    ElMessage.warning('暂无汇总数据可导出')
+    return
+  }
+  try {
+    const workbook = XLSX.utils.book_new()
+    const summaryEl = document.getElementById('dyhztable')
+    const summarySheet = XLSX.utils.table_to_sheet(summaryEl, { raw: true })
+    convertNumericCells(summarySheet, 5, 5 + workHourCols.length - 1)
+    XLSX.utils.book_append_sheet(workbook, summarySheet, '汇总')
+    XLSX.writeFile(workbook, `年度打样效率统计_汇总_${currentDate.value}.xlsx`)
+  } catch (error) {
+    console.error('导出失败:', error)
+    ElMessage.error('导出数据失败,请重试')
+  }
+}
+
+// 仅导出下方明细表(全量明细 allDetailData)
+const exportDetail = () => {
+  if (!allDetailData.value.length) {
+    ElMessage.warning('暂无明细数据可导出')
+    return
+  }
+  try {
+    const workbook = XLSX.utils.book_new()
+    const detailHeader = ['年月', '客户编号', '客户名称', '工单编号', '成品名称', '印件及工序', ...workHourCols.map(col => col.prop)]
+    const detailRows = allDetailData.value.map(row => detailHeader.map(col => (row[col] === undefined || row[col] === null ? '' : row[col])))
+    const detailSheet = XLSX.utils.aoa_to_sheet([detailHeader, ...detailRows])
+    convertNumericCells(detailSheet, 6, 6 + workHourCols.length - 1)
+    XLSX.utils.book_append_sheet(workbook, detailSheet, '明细')
+    XLSX.writeFile(workbook, `年度打样效率统计_明细_${currentDate.value}.xlsx`)
+  } catch (error) {
+    console.error('导出失败:', error)
+    ElMessage.error('导出数据失败,请重试')
+  }
+}
+</script>
+
+<style scoped>
+.form-container {
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.form-column {
+  margin-right: 15px;
+}
+
+.form-column .el-form-item .el-input {
+  width: 150px;
+}
+
+@media screen and (max-width: 768px) {
+  .form-column {
+    flex: 1 0 100%;
+    margin-right: 0;
+  }
+}
+
+.JKWTree-tree {
+  background-color: #fff;
+  padding: 10px;
+  margin-right: 20px;
+  max-height: calc(100vh - 230px);
+  overflow-y: auto;
+  overflow-x: hidden;
+}
+
+.JKWTree-tree h3 {
+  font-size: 15px;
+  font-weight: 700;
+  margin: 10px 0;
+}
+
+/* 年份节点粉色,月份节点蓝色 */
+:deep(.el-tree > .el-tree-node > .el-tree-node__content .el-tree-node__label) {
+  color: #ff00ff;
+  font-weight: 700;
+}
+
+:deep(.el-tree-node__children .el-tree-node__label) {
+  color: #1e3fd8;
+}
+
+/* 树选中节点:文字红色加粗,与 ProductOutputRate 一致 */
+:deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+  color: red !important;
+  font-weight: bold !important;
+}
+
+/* 选中某行时的背景色 */
+:deep(.el-table__body tr.current-row) > td {
+  background: #ff80ff !important;
+}
+
+/* 合计行背景色 */
+:deep(.el-table__body tr.total-row) > td {
+  background: #ffff00 !important;
+}
+
+/* 所有合计行都 sticky 冻结在表格底部,按 bottom 值层层叠放 */
+:deep(.el-table__body tr.total-row) {
+  position: sticky;
+  z-index: 3;
+}
+/* 倒数第 1 个合计行 bottom:0 */
+:deep(.el-table__body tr.total-row-sticky-1) {
+  bottom: 0;
+}
+/* 倒数第 2 个合计行 bottom:25px(行高 25px) */
+:deep(.el-table__body tr.total-row-sticky-2) {
+  bottom: 25px;
+}
+
+:deep(.el-tree-node__label) {
+  font-size: 13px;
+}
+
+:deep(.el-table td .cell) {
+  line-height: 20px !important;
+}
+
+.bt {
+  margin-left: 2px !important;
+  padding: 3px !important;
+  font-size: 12px;
+}
+
+.gva-table-box {
+  padding: 0px !important;
+}
+</style>

+ 285 - 0
src/view/DecisionSupport/CompletionOrderProductionCycleStatistics.vue

@@ -0,0 +1,285 @@
+<template>
+    <div>
+      <layout>
+        <layout-header>
+          <div>
+            <el-form class="demo-form-inline" inline @submit.prevent>
+              <el-form-item>
+                <el-input v-model="searchInfo" placeholder="搜索工单编号/产品名称" clearable
+                          style="width: 200px" @keyup.enter="handleSearch" />
+                <el-button type="primary" class="bt" icon="search" @click="handleSearch">搜索</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="exportExcel">导出Excel</el-button>
+              </el-form-item>
+            </el-form>
+          </div>
+        </layout-header>
+
+        <layout>
+          <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
+            <div class="JKWTree-tree">
+              <h3>完工工单生产周期统计</h3>
+              <el-tree ref="treeRef" :data="treeData" :props="defaultProps" node-key="key"
+                       highlight-current @node-click="handleNodeClick">
+              </el-tree>
+            </div>
+          </layout-sider>
+
+          <layout-content>
+            <el-main>
+              <div class="gva-table-box">
+                <el-table id="cops_table" ref="tableRef"
+                          style="width: 100%; height: 72vh"
+                          tooltip-effect="dark" border size="small"
+                          highlight-current-row
+                          :row-style="{ height: '25px' }"
+                          :header-row-style="{ height: '22px' }"
+                          :cell-style="{ padding: '0px' }"
+                          :header-cell-style="{ padding: '0px' }"
+                          :data="tableData"
+                          v-loading="loading"
+                          :show-overflow-tooltip="true">
+                  <el-table-column v-for="c in tableCols" :key="c.prop"
+                                   align="center" :label="c.label" :prop="c.prop"
+                                   :width="c.width" :min-width="c.minWidth || undefined" />
+                </el-table>
+              </div>
+              <div class="pagination-box">
+                <el-pagination
+                  v-model:current-page="currentPage"
+                  v-model:page-size="pageSize"
+                  :page-sizes="[50, 100, 200, 500]"
+                  :total="total"
+                  layout="total, sizes, prev, pager, next, jumper"
+                  background
+                  @current-change="handlePageChange"
+                  @size-change="handleSizeChange" />
+              </div>
+            </el-main>
+          </layout-content>
+        </layout>
+      </layout>
+    </div>
+  </template>
+
+  <script setup>
+  import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue'
+  import { ref, nextTick, onMounted } from 'vue'
+  import { ElMessage } from 'element-plus'
+  import * as XLSX from 'xlsx'
+  import { CopsTab, CopsList } from '@/api/DecisionSupport/decision.js'
+
+  defineOptions({ name: 'CompletionOrderProductionCycleStatistics' })
+
+  const treeRef = ref(null)
+  const tableRef = ref(null)
+  const treeData = ref([])
+  const tableData = ref([])
+  const defaultProps = { children: 'children', label: 'label' }
+  const searchInfo = ref('')
+  const loading = ref(false)
+  let requestId = 0
+
+  // 分页
+  const currentPage = ref(1)
+  const pageSize = ref(50)
+  const total = ref(0)
+
+  const currentDate = ref('')
+  const currentCode = ref('')
+
+  // 表格列
+  const tableCols = [
+    { prop: '生产分类', label: '生产分类', width: 80 },
+    { prop: '工单编号', label: '工单编号', width: 110 },
+    { prop: '印件代号', label: '印件代号', width: 110 },
+    { prop: '产品代号', label: '产品代号', width: 120 },
+    { prop: '产品名称', label: '产品名称', minWidth: 280 },
+    { prop: '订单数量', label: '订单数量', width: 90 },
+    { prop: '实际投料', label: '实际投料', width: 90 },
+    { prop: '计量单位', label: '计量单位', width: 80 },
+    { prop: '入仓数量', label: '入仓数量', width: 90 },
+    { prop: '生产公休', label: '生产公休', width: 80 },
+    { prop: '生产周期', label: '生产周期', width: 80 },
+    { prop: '检验公休', label: '检验公休', width: 80 },
+    { prop: '检验周期', label: '检验周期', width: 80 },
+    { prop: '工单公休', label: '工单公休', width: 80 },
+    { prop: '工单周期', label: '工单周期', width: 80 },
+    { prop: '接单日期', label: '接单日期', width: 100 },
+    { prop: '生产开工日期', label: '生产开工日期', width: 110 },
+    { prop: '模切开工日期', label: '模切开工日期', width: 110 },
+    { prop: '检验日期', label: '检验日期', width: 100 },
+    { prop: '入仓完工日期', label: '入仓完工日期', width: 110 },
+    { prop: '目标合格率', label: '目标合格率', width: 100 },
+    { prop: '实际合格率', label: '实际合格率', width: 100 },
+    { prop: '客户代号', label: '客户代号', width: 90 },
+    { prop: '客户名称', label: '客户名称', minWidth: 180 },
+    { prop: '销售订单号', label: '销售订单号', width: 120 },
+  ]
+
+  const getTreeData = async () => {
+    try {
+      const res = await CopsTab()
+      if (res.code === 0 && res.data) {
+        const data = res.data
+        const tree = []
+        for (const [key, items] of Object.entries(data)) {
+          const [date, total] = key.split('-')
+          const children = items.map(it => ({
+            label: `${it.name || '(无客户)'}【${it.code}】(${it.total})`,
+            code: it.code,
+            date: date,
+            total: it.total,
+          }))
+          tree.push({
+            label: `${date.substring(0, 4)}-${date.substring(4)}月 (工单:${total})`,
+            date: date,
+            children,
+          })
+        }
+        treeData.value = tree
+      }
+    } catch (e) {
+      console.error('获取左侧菜单失败:', e)
+    }
+  }
+
+  const fetchData = async () => {
+    const id = ++requestId
+    loading.value = true
+    tableData.value = []
+    try {
+      const params = { page: currentPage.value, limit: pageSize.value }
+      if (currentDate.value) params.date = currentDate.value
+      if (currentCode.value) params.code = currentCode.value
+      if (searchInfo.value.trim()) params.search = searchInfo.value.trim()
+      const res = await CopsList(params)
+      if (id !== requestId) return
+      if (res.code === 0) {
+        const data = res.data || {}
+        tableData.value = data.list || []
+        total.value = data.total || 0
+      }
+    } catch (e) {
+      if (id !== requestId) return
+      console.error('请求出错:', e)
+      ElMessage.error('查询失败')
+    } finally {
+      if (id === requestId) loading.value = false
+    }
+  }
+
+  const handlePageChange = (p) => {
+    currentPage.value = p
+    fetchData()
+  }
+
+  const handleSizeChange = (s) => {
+    pageSize.value = s
+    currentPage.value = 1
+    fetchData()
+  }
+
+  const handleNodeClick = (node) => {
+    tableData.value = []
+    currentPage.value = 1
+    searchInfo.value = ''
+    currentCode.value = ''
+    if (node.code) {
+      // 客户节点
+      currentDate.value = node.date
+      currentCode.value = node.code
+    } else {
+      // 月份节点
+      currentDate.value = node.date
+    }
+    fetchData()
+  }
+
+  const handleSearch = () => {
+    currentPage.value = 1
+    if (!searchInfo.value.trim()) {
+      fetchData()
+      return
+    }
+    // 搜索时不带左侧筛选,全局搜索
+    fetchData()
+  }
+
+  const exportExcel = async () => {
+    try {
+      const params = { export: 1 }
+      if (currentDate.value) params.date = currentDate.value
+      if (currentCode.value) params.code = currentCode.value
+      if (searchInfo.value.trim()) params.search = searchInfo.value.trim()
+      const res = await CopsList(params)
+      if (res.code !== 0) { ElMessage.error('导出失败'); return }
+      const rows = (res.data && res.data.list) || []
+      if (!rows.length) { ElMessage.warning('没有可导出的数据'); return }
+
+      const exportRows = rows.map(row => {
+        const obj = {}
+        tableCols.forEach(c => {
+          obj[c.label] = row[c.prop] === null || row[c.prop] === undefined ? '' : row[c.prop]
+        })
+        return obj
+      })
+      const ws = XLSX.utils.json_to_sheet(exportRows, { header: tableCols.map(c => c.label) })
+      const wb = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(wb, ws, '完工工单生产周期统计')
+      const filename = `完工工单生产周期统计_${new Date().toISOString().slice(0, 10)}.xlsx`
+      XLSX.writeFile(wb, filename)
+      ElMessage.success(`已导出 ${exportRows.length} 条`)
+    } catch (e) {
+      console.error('导出失败:', e)
+      ElMessage.error('导出失败')
+    }
+  }
+
+  onMounted(async () => {
+    await getTreeData()
+    // 不自动触发数据加载;等用户点击左侧节点后再加载
+  })
+  </script>
+
+  <style scoped>
+  .JKWTree-tree {
+    background-color: #fff;
+    padding: 10px;
+    margin-right: 10px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
+  }
+  .JKWTree-tree h3 {
+    font-size: 14px;
+    font-weight: 700;
+    margin: 8px 0;
+  }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
+  :deep(.el-table td .cell) {
+    line-height: 22px !important;
+  }
+  :deep(.el-table__body tr.current-row) > td {
+    background: #ff80ff !important;
+  }
+  .bt {
+    margin-left: 2px !important;
+    padding: 3px !important;
+    font-size: 12px;
+  }
+  .gva-table-box {
+    padding: 0px !important;
+  }
+  .pagination-box {
+    display: flex;
+    justify-content: flex-end;
+    padding: 8px 4px 0;
+  }
+  </style>

+ 505 - 0
src/view/DecisionSupport/CustomerQualityStatistics.vue

@@ -0,0 +1,505 @@
+<template>
+    <div>
+      <layout>
+        <layout-header>
+          <div class="toolbar">
+            <el-button type="primary" class="bt" icon="switch" @click="switchView">切换显示</el-button>
+            <el-input v-model="searchInfo" class="search-input" placeholder="请输入关键词" clearable
+                      @keyup.enter="onsearch" />
+            <el-button type="primary" class="bt" icon="search" @click="onsearch">搜索</el-button>
+            <el-button v-if="viewMode === 'A'" type="primary" class="bt" icon="download"
+                       @click="exportExcel('detail')">导出Excel</el-button>
+            <template v-else>
+              <el-button type="primary" class="bt" icon="download"
+                         @click="exportExcel('summary')">导出Excel(汇总)</el-button>
+              <el-button type="primary" class="bt" icon="download"
+                         @click="exportExcel('detail')">导出Excel(明细)</el-button>
+            </template>
+          </div>
+        </layout-header>
+
+        <layout>
+          <!--    左侧树侧形结构-->
+          <layout-sider :resize-directions="['right']" :width="250" style="margin-right: 10px;">
+            <div class="JKWTree-tree">
+              <h3>{{ viewMode === 'A' ? '客诉质量缺陷统计A' : '客诉质量缺陷统计B' }}</h3>
+              <!-- 视图A:年 -> 缺陷关键字 -->
+              <el-tree v-if="viewMode === 'A'" ref="treeRefA" :data="treeDataA" :props="defaultProps"
+                       node-key="key" highlight-current @node-click="handleNodeClickA">
+              </el-tree>
+              <!-- 视图B:年 -> 客户 -->
+              <el-tree v-else ref="treeRefB" :data="treeDataB" :props="defaultProps"
+                       node-key="key" highlight-current @node-click="handleNodeClickB">
+              </el-tree>
+            </div>
+          </layout-sider>
+
+          <!-- 右侧区域 -->
+          <layout-content>
+          <el-main>
+            <!-- 视图A:客诉明细 -->
+            <div v-if="viewMode === 'A'" class="gva-table-box">
+              <el-table ref="tableRefA" id="tableA" style="width: 100%;height: 72vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="tableData" border
+                        size="small"
+                        highlight-current-row="true" :show-overflow-tooltip="true">
+               <el-table-column align="center" label="客诉单号" prop="客诉单号" width="110" />
+               <el-table-column align="center" label="客诉日期" prop="客诉日期" width="95">
+                 <template #default="{ row }">{{ formatDate(row.客诉日期) }}</template>
+               </el-table-column>
+               <el-table-column align="center" label="客诉方式" prop="客诉方式" width="90" />
+               <el-table-column align="center" label="订单编号" prop="订单编号" width="120" />
+               <el-table-column align="center" label="产品编号" prop="产品编号" width="110" />
+               <el-table-column align="center" label="产品名称" prop="产品名称" min-width="200" />
+               <el-table-column align="center" label="客户编号" prop="客户编号" width="85" />
+               <el-table-column align="center" label="客户名称" prop="客户名称" width="170" />
+               <el-table-column align="center" label="客诉描述" prop="客诉描述" min-width="260" />
+               <el-table-column align="center" label="缺陷关键字" prop="缺陷关键字" width="95" />
+               <el-table-column align="center" label="客诉性质" prop="客诉性质" width="80" />
+               <el-table-column align="center" label="扣分" prop="扣分" width="70" />
+               <el-table-column align="center" label="主要责任部门" prop="主要责任部门" width="105" />
+              </el-table>
+            </div>
+
+            <!-- 视图B:月度汇总 + 客诉明细 -->
+            <div v-else class="gva-table-box">
+              <el-table id="summaryTable" style="width: 100%" height="180" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="summaryData" border
+                        size="small"
+                        highlight-current-row="true" :show-overflow-tooltip="true"
+                        @row-click="handleSummaryRowClick">
+               <el-table-column align="center" label="年月" prop="年月" width="80" />
+               <el-table-column align="center" label="客户编号" prop="客户编号" width="90" />
+               <el-table-column align="center" label="客户名称" prop="客户名称" width="200" />
+               <el-table-column align="center" label="年度投诉次数" prop="年度投诉次数" width="110" />
+               <el-table-column v-for="item in bMonthCols" :key="item.prop" align="center"
+                                :label="item.label" :prop="item.prop" width="70" />
+              </el-table>
+
+              <el-table ref="tableRefB" id="tableB" style="width: 100%;margin-top: 8px;height: calc(72vh - 200px)" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="tableData" border
+                        size="small"
+                        highlight-current-row="true" :show-overflow-tooltip="true">
+               <el-table-column align="center" label="客诉单号" prop="客诉单号" width="110" />
+               <el-table-column align="center" label="客诉日期" prop="客诉日期" width="95">
+                 <template #default="{ row }">{{ formatDate(row.客诉日期) }}</template>
+               </el-table-column>
+               <el-table-column align="center" label="客诉方式" prop="客诉方式" width="90" />
+               <el-table-column align="center" label="订单编号" prop="订单编号" width="120" />
+               <el-table-column align="center" label="产品编号" prop="产品编号" width="110" />
+               <el-table-column align="center" label="产品名称" prop="产品名称" min-width="180" />
+               <el-table-column align="center" label="客户编号" prop="客户编号" width="85" />
+               <el-table-column align="center" label="客户名称" prop="客户名称" width="170" />
+               <el-table-column align="center" label="客诉描述" prop="客诉描述" min-width="220" />
+               <el-table-column align="center" label="缺陷关键字" prop="缺陷关键字" width="95" />
+               <el-table-column align="center" label="客诉性质" prop="客诉性质" width="80" />
+               <el-table-column align="center" label="扣分" prop="扣分" width="70" />
+               <el-table-column align="center" label="主要责任部门" prop="主要责任部门" width="105" />
+               <el-table-column align="center" label="次要责任部门" prop="次要责任部门" width="105" />
+               <el-table-column align="center" label="创建用户" prop="创建用户" width="130" />
+               <el-table-column align="center" label="创建时间" prop="创建时间" width="150">
+                 <template #default="{ row }">{{ formatDateTime(row.创建时间) }}</template>
+               </el-table-column>
+               <el-table-column align="center" label="结案时间" prop="结案时间" width="100">
+                 <template #default="{ row }">{{ formatDate(row.结案时间) }}</template>
+               </el-table-column>
+              </el-table>
+            </div>
+          </el-main>
+        </layout-content>
+        </layout>
+      </layout>
+    </div>
+  </template>
+  <script setup>
+  import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
+
+  import {ref} from 'vue'
+  import { ElMessage } from 'element-plus'
+  import * as XLSX from 'xlsx'
+  import { KhtjLeftA, KhtjListA, KhtjLeftB, KhtjListB } from "@/api/DecisionSupport/decision.js"
+
+  defineOptions({name: 'CustomerQualityStatistics'})
+
+  const defaultProps = {
+    children: 'children',
+    label: 'label'
+  }
+  // 当前视图:A(按缺陷关键字) / B(按客户)
+  const viewMode = ref('A')
+
+  const treeRefA = ref(null)
+  const treeRefB = ref(null)
+  const treeDataA = ref([])
+  const treeDataB = ref([])
+
+  const tableData = ref([])
+  const summaryData = ref([])
+
+  // 搜索关键词
+  const searchInfo = ref('')
+
+  // 视图A当前选择:年份、缺陷关键字
+  const currentYearA = ref('')
+  const currentKeyword = ref('')
+  // 视图B当前选择:年份、客户
+  const currentYearB = ref('')
+  const currentCustomer = ref('')
+
+  // 防止快速切换时旧请求覆盖新数据(汇总与明细各自独立计数,避免互相作废)
+  let requestId = 0
+  let summaryRequestId = 0
+  let detailRequestId = 0
+
+  // 视图B月份列 月份01 ~ 月份12
+  const bMonthCols = Array.from({ length: 12 }, (_, i) => {
+    const month = String(i + 1).padStart(2, '0')
+    return { label: `月份${month}`, prop: `月份${month}` }
+  })
+
+  // 日期格式化 YYYY.MM.DD
+  const formatDate = (val) => {
+    if (!val) return ''
+    return String(val).slice(0, 10).replace(/-/g, '.')
+  }
+  // 日期时间格式化 YYYY.MM.DD HH:mm:ss
+  const formatDateTime = (val) => {
+    if (!val) return ''
+    const s = String(val)
+    return s.slice(0, 10).replace(/-/g, '.') + ' ' + (s.slice(11, 19) || '')
+  }
+
+  // =========== 视图A:年 -> 缺陷关键字 ===========
+  const loadTreeA = async () => {
+    if (treeDataA.value.length) {
+      return
+    }
+    try {
+      const res = await KhtjLeftA()
+      if (res.code === 0 && Array.isArray(res.data)) {
+        treeDataA.value = res.data.map(yearItem => ({
+          label: `${yearItem.年份}【客诉 ${yearItem.次数} 次】`,
+          key: `A-Y${yearItem.年份}`,
+          year: String(yearItem.年份),
+          keyword: '',
+          children: (yearItem.children || []).map(kItem => ({
+            label: `${kItem.关键字} (客诉 ${kItem.次数} 次)`,
+            key: `A-Y${yearItem.年份}-K${kItem.关键字}`,
+            year: String(yearItem.年份),
+            keyword: kItem.关键字
+          }))
+        }))
+      } else {
+        console.error('获取数据失败:', res.msg)
+      }
+    } catch (error) {
+      console.error('请求出错:', error)
+    }
+  }
+
+  const fetchListA = async () => {
+    if (!currentYearA.value) {
+      return
+    }
+    const id = ++requestId
+    tableData.value = []
+    try {
+      const res = await KhtjListA({
+        year: currentYearA.value,
+        keyword: currentKeyword.value,
+        search: searchInfo.value.trim()
+      })
+      if (id !== requestId) {
+        return
+      }
+      tableData.value = res.data || []
+    } catch (error) {
+      if (id !== requestId) {
+        return
+      }
+      console.error('请求出错:', error)
+      tableData.value = []
+    }
+  }
+
+  // 点击年份节点查询全年,点击缺陷关键字节点查询该类缺陷
+  const handleNodeClickA = (nodeData) => {
+    if (!nodeData || !nodeData.year) {
+      return
+    }
+    currentYearA.value = nodeData.year
+    currentKeyword.value = nodeData.keyword || ''
+    fetchListA()
+  }
+
+  // =========== 视图B:年 -> 客户 ===========
+  const loadTreeB = async () => {
+    if (treeDataB.value.length) {
+      return
+    }
+    try {
+      const res = await KhtjLeftB()
+      if (res.code === 0 && Array.isArray(res.data)) {
+        treeDataB.value = res.data.map(yearItem => ({
+          label: String(yearItem.年份),
+          key: `B-Y${yearItem.年份}`,
+          year: String(yearItem.年份),
+          customer: '',
+          children: (yearItem.客户 || []).map(cItem => ({
+            label: `${cItem.客户编号}【${cItem.客户名称}】`,
+            key: `B-Y${yearItem.年份}-C${cItem.客户编号}`,
+            year: String(yearItem.年份),
+            customer: cItem.客户编号 || ''
+          }))
+        }))
+      } else {
+        console.error('获取数据失败:', res.msg)
+      }
+    } catch (error) {
+      console.error('请求出错:', error)
+    }
+  }
+
+  // 查询月度汇总(上方表格),明细表清空
+  const fetchSummaryB = async () => {
+    if (!currentYearB.value) {
+      return
+    }
+    const id = ++summaryRequestId
+    summaryData.value = []
+    tableData.value = []
+    try {
+      const res = await KhtjListB({
+        year: currentYearB.value,
+        customer: currentCustomer.value,
+        search: searchInfo.value.trim()
+      })
+      if (id !== summaryRequestId) {
+        return
+      }
+      summaryData.value = (res.data && res.data.summary) || []
+    } catch (error) {
+      if (id !== summaryRequestId) {
+        return
+      }
+      console.error('请求出错:', error)
+      summaryData.value = []
+    }
+  }
+
+  // 查询某个客户的客诉明细(下方表格),需点击上方汇总行
+  const fetchDetailB = async (customer) => {
+    if (!currentYearB.value) {
+      return
+    }
+    const id = ++detailRequestId
+    tableData.value = []
+    try {
+      const res = await KhtjListB({
+        year: currentYearB.value,
+        customer: customer,
+        search: searchInfo.value.trim()
+      })
+      if (id !== detailRequestId) {
+        return
+      }
+      tableData.value = (res.data && res.data.list) || []
+    } catch (error) {
+      if (id !== detailRequestId) {
+        return
+      }
+      console.error('请求出错:', error)
+      tableData.value = []
+    }
+  }
+
+  // 点击上方汇总行才加载该客户的明细
+  const handleSummaryRowClick = (row) => {
+    fetchDetailB(row.客户编号 || '')
+  }
+
+  // 点击年份节点查询该年全部客户汇总,点击客户节点查询该客户汇总
+  const handleNodeClickB = (nodeData) => {
+    if (!nodeData || !nodeData.year) {
+      return
+    }
+    currentYearB.value = nodeData.year
+    currentCustomer.value = nodeData.customer || ''
+    fetchSummaryB()
+  }
+
+  // =========== 搜索与导出(导出前端生成,搜索需先点击左侧年份节点) ===========
+  const onsearch = () => {
+    if (viewMode.value === 'A') {
+      if (!currentYearA.value) {
+        ElMessage.warning('请先点击左侧年份节点')
+        return
+      }
+      fetchListA()
+    } else {
+      if (!currentYearB.value) {
+        ElMessage.warning('请先点击左侧年份节点')
+        return
+      }
+      fetchSummaryB()
+      if (currentCustomer.value) {
+        fetchDetailB(currentCustomer.value)
+      }
+    }
+  }
+
+  // 将页面表格导出为Excel
+  const exportTable = (tableId, fileName, numericColumns = []) => {
+    const el = document.getElementById(tableId)
+    if (!el) {
+      ElMessage.warning('暂无可导出的数据')
+      return
+    }
+    try {
+      const worksheet = XLSX.utils.table_to_sheet(el, { raw: true })
+      const range = XLSX.utils.decode_range(worksheet['!ref'])
+      numericColumns.forEach(colIndex => {
+        for (let row = range.s.r + 1; row <= range.e.r; row++) {
+          const cellAddress = XLSX.utils.encode_cell({ r: row, c: colIndex })
+          if (worksheet[cellAddress]) {
+            const cellValue = worksheet[cellAddress].v
+            const numValue = Number(cellValue)
+            if (!isNaN(numValue) && cellValue !== '') {
+              worksheet[cellAddress].t = 'n'
+              worksheet[cellAddress].v = numValue
+            }
+          }
+        }
+      })
+      const workbook = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
+      XLSX.writeFile(workbook, fileName)
+    } catch (error) {
+      console.error('导出失败:', error)
+      ElMessage.error('导出数据失败,请重试')
+    }
+  }
+
+  // 视图A:导出客诉明细;视图B:type=summary 导出月度汇总、type=detail 导出客诉明细
+  const exportExcel = (type) => {
+    if (viewMode.value === 'A') {
+      if (!currentYearA.value) {
+        ElMessage.warning('请先点击左侧年份节点')
+        return
+      }
+      if (!tableData.value.length) {
+        ElMessage.warning('暂无可导出的数据')
+        return
+      }
+      exportTable('tableA', '客诉质量缺陷统计A.xlsx')
+      return
+    }
+    if (!currentYearB.value) {
+      ElMessage.warning('请先点击左侧年份节点')
+      return
+    }
+    if (type === 'summary') {
+      if (!summaryData.value.length) {
+        ElMessage.warning('暂无可导出的数据')
+        return
+      }
+      // 客户名称之后(年度投诉次数及12个月份)转为数字
+      const numericColumns = Array.from({ length: 13 }, (_, i) => i + 3)
+      exportTable('summaryTable', '客诉质量缺陷统计B_月度汇总.xlsx', numericColumns)
+    } else {
+      if (!tableData.value.length) {
+        ElMessage.warning('暂无可导出的数据')
+        return
+      }
+      exportTable('tableB', '客诉质量缺陷统计B_客诉明细.xlsx')
+    }
+  }
+
+  // =========== 初始化当前视图与切换(进入页面不自动选中节点、不自动查询) ===========
+  const initCurrentView = async () => {
+    if (viewMode.value === 'A') {
+      await loadTreeA()
+    } else {
+      await loadTreeB()
+    }
+  }
+
+  // 切换显示A/B视图
+  const switchView = () => {
+    viewMode.value = viewMode.value === 'A' ? 'B' : 'A'
+    tableData.value = []
+    summaryData.value = []
+    currentYearA.value = ''
+    currentKeyword.value = ''
+    currentYearB.value = ''
+    currentCustomer.value = ''
+    initCurrentView()
+  }
+
+  initCurrentView()
+
+  </script>
+
+  <style scoped>
+  .JKWTree-tree {
+    background-color: #fff;
+    padding: 10px;
+    margin-right: 20px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
+  }
+  .JKWTree-tree h3 {
+    font-size: 15px;
+    font-weight: 700;
+    margin: 10px 0;
+  }
+
+  /* 选中某行时的背景色 */
+  :deep(.el-table__body tr.current-row) > td {
+    background: #ff80ff !important;
+  }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
+  </style>
+  <style scoped>
+  :deep(.el-table td .cell) {
+    line-height: 20px !important;
+  }
+  .bt{
+    margin-left: 2px !important;
+    padding: 3px !important;
+    font-size: 12px;
+  }
+  .toolbar{
+    display: flex;
+    align-items: center;
+    gap: 8px;
+    flex-wrap: nowrap;
+  }
+  .search-input{
+    width: 200px;
+  }
+  :deep(.el-form-item){
+    margin-bottom: 0px !important;
+  }
+  .el-tabs__header{
+    margin: 0px !important;
+  }
+  .gva-table-box{
+    padding: 0px !important;
+  }
+  </style>

+ 285 - 0
src/view/DecisionSupport/EquipmentWeekDataStatistics.vue

@@ -0,0 +1,285 @@
+<template>
+    <div>
+      <layout>
+        <layout-header>
+          <div>
+            <el-form class="demo-form-inline">
+              <el-form-item>
+                <el-button type="primary" class="bt" icon="download" @click="exportSummaryExcel">导出汇总</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="exportDetailExcel">导出明细</el-button>
+              </el-form-item>
+            </el-form>
+          </div>
+        </layout-header>
+
+        <layout>
+          <layout-sider :resize-directions="['right']" :width="200" style="margin-right: 10px;">
+            <div class="JKWTree-tree">
+              <h3>设备周数据统计</h3>
+              <el-tree ref="treeRef" :data="treeData" :props="defaultProps" node-key="key"
+                       highlight-current @node-click="handleNodeClick">
+              </el-tree>
+            </div>
+          </layout-sider>
+
+          <layout-content>
+          <el-main>
+            <div class="gva-table-box">
+              <el-table id="eqwdt_summary" ref="summaryTableRef" style="width: 100%;height: 40vh"
+                        tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '22px' }"
+                        :data="summaryData" border size="small"
+                        highlight-current-row @row-click="summaryRowClick" :show-overflow-tooltip="true">
+                <el-table-column v-for="c in summaryCols" :key="c.prop"
+                                 align="center" :label="c.label" :prop="c.prop" :width="c.width"
+                                 :min-width="c.minWidth || undefined" />
+              </el-table>
+            </div>
+
+            <div class="gva-table-box" style="margin-top: 8px;">
+              <div class="sub-title">
+                <!-- <span v-if="currentMachine" class="sub-title-info">当前筛选机台:{{ currentMachine }}</span> -->
+              </div>
+              <el-table id="eqwdt_detail" ref="detailTableRef" style="width: 100%;height: 36vh"
+                        tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '22px' }"
+                        :data="detailData" border size="small"
+                        highlight-current-row :show-overflow-tooltip="true">
+                <el-table-column v-for="c in detailCols" :key="c.prop"
+                                 align="center" :label="c.label" :prop="c.prop" :width="c.width"
+                                 :min-width="c.minWidth || undefined" />
+              </el-table>
+            </div>
+          </el-main>
+        </layout-content>
+        </layout>
+      </layout>
+    </div>
+  </template>
+
+  <script setup>
+  import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue';
+
+  import { ref, nextTick, onMounted, computed } from 'vue'
+  import { ElMessage } from "element-plus";
+  import * as XLSX from 'xlsx'
+  import { EqwdtLeft, EqwdtList } from "@/api/DecisionSupport/decision.js"
+
+  defineOptions({ name: 'EquipmentWeekDataStatistics' })
+
+  const treeRef = ref(null)
+  const summaryTableRef = ref(null)
+  const detailTableRef = ref(null)
+  const treeData = ref([])
+  const defaultProps = { children: 'children', label: 'label' }
+
+  const currentMachine = ref('')
+  const rangeStart = ref('')
+  const rangeEnd = ref('')
+
+  const summaryData = ref([])
+  const allSummaryData = ref([])
+  const detailData = ref([])
+  const allDetailData = ref([])
+  let requestId = 0
+
+  const dateRangeText = () => {
+    if (rangeStart.value && rangeEnd.value) {
+      return `${rangeStart.value} ~ ${rangeEnd.value}`
+    }
+    return '加载中...'
+  }
+
+  // 上方汇总表列:设备编号/设备名称 + 最近7天每天的 产量/工时(动态日期列)
+  const dayList = ref([])
+  const summaryCols = computed(() => {
+    const cols = [
+      { prop: '机台编号', label: '设备编号', width: 110 },
+      { prop: '设备名称', label: '设备名称', minWidth: 200 },
+    ]
+    dayList.value.forEach(d => {
+      cols.push({ prop: `产量_${d}`, label: `产量(${d})`, width: 88 })
+      cols.push({ prop: `工时_${d}`, label: `工时(${d})`, width: 88 })
+    })
+    return cols
+  })
+
+  // 下方明细表列
+  const detailCols = [
+    { prop: '日期', label: '日期', width: 100 },
+    { prop: '机台编号', label: '机台编号', width: 110 },
+    { prop: '设备名称', label: '设备名称', minWidth: 200 },
+    { prop: '工单编号', label: '工单编号', width: 110 },
+    { prop: '印件及工序', label: '印件及工序', width: 110 },
+    { prop: '产品编号', label: '产品编号', width: 120 },
+    { prop: '成品名称', label: '成品名称', minWidth: 220 },
+    { prop: '客户名称', label: '客户名称', width: 160 },
+    { prop: '产量', label: '产量', width: 80 },
+    { prop: '设备运行工时', label: '设备运行工时', width: 120 },
+    { prop: '装版工时', label: '装版工时', width: 90 },
+    { prop: '保养工时', label: '保养工时', width: 90 },
+    { prop: '打样工时', label: '打样工时', width: 90 },
+    { prop: '异常停机工时', label: '异常停机工时', width: 120 },
+    { prop: '制程废品', label: '制程废品', width: 90 },
+    { prop: '制程次品', label: '制程次品', width: 90 },
+  ]
+
+  const getTreeData = async () => {
+    try {
+      const res = await EqwdtLeft()
+      if (res.code === 0 && Array.isArray(res.data)) {
+        treeData.value = res.data
+      }
+    } catch (e) {
+      console.error('获取左侧菜单失败:', e)
+    }
+  }
+
+  const fetchData = async () => {
+    const id = ++requestId
+    allSummaryData.value = []
+    allDetailData.value = []
+    summaryData.value = []
+    detailData.value = []
+    try {
+      const res = await EqwdtList({ machine: currentMachine.value })
+      if (id !== requestId) return
+      const data = res.data || {}
+      allSummaryData.value = data.summary || []
+      allDetailData.value = data.detail || []
+      summaryData.value = allSummaryData.value
+      dayList.value = data.days || []
+      // 保存后端返回的日期范围
+      const range = data.range || {}
+      rangeStart.value = range.start || ''
+      rangeEnd.value = range.end || ''
+      // 左侧直接点机台:明细按机台过滤
+      if (currentMachine.value) {
+        detailData.value = allDetailData.value.filter(r => r.机台编号 === currentMachine.value)
+      }
+    } catch (e) {
+      if (id !== requestId) return
+      console.error('请求出错:', e)
+    }
+  }
+
+  const handleNodeClick = (node) => {
+    if (!node) return
+    if (node.machine) {
+      currentMachine.value = node.machine
+    } else {
+      // 车间节点:看全部
+      currentMachine.value = ''
+    }
+    fetchData()
+  }
+
+  const summaryRowClick = (row) => {
+    if (!row || !row.机台编号) return
+    // 点击上方汇总行 → 仅下方明细按机台编号过滤,上方汇总表保持不变
+    currentMachine.value = row.机台编号
+    detailData.value = allDetailData.value.filter(r => r.机台编号 === row.机台编号)
+  }
+
+  const exportSummaryExcel = () => {
+    try {
+      const el = document.getElementById('eqwdt_summary')
+      if (!el) { ElMessage.warning('暂无汇总表'); return }
+      const sheet = XLSX.utils.table_to_sheet(el, { raw: true })
+      const wb = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(wb, sheet, '机台汇总')
+      const name = rangeStart.value && rangeEnd.value
+        ? `设备周数据统计_汇总_${rangeStart.value}_${rangeEnd.value}.xlsx`
+        : '设备周数据统计_汇总.xlsx'
+      XLSX.writeFile(wb, name)
+      ElMessage.success('汇总已导出')
+    } catch (e) {
+      console.error('导出失败:', e)
+      ElMessage.error('导出失败')
+    }
+  }
+
+  const exportDetailExcel = () => {
+    try {
+      if (!detailData.value.length) { ElMessage.warning('暂无可导出的明细数据'); return }
+      const ws = XLSX.utils.aoa_to_sheet([
+        detailCols.map(c => c.label),
+        ...detailData.value.map(row => detailCols.map(c => row[c.prop] === null || row[c.prop] === undefined ? '' : row[c.prop]))
+      ])
+      const wb = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(wb, ws, '工单明细')
+      const name = rangeStart.value && rangeEnd.value
+        ? `设备周数据统计_明细_${rangeStart.value}_${rangeEnd.value}.xlsx`
+        : '设备周数据统计_明细.xlsx'
+      XLSX.writeFile(wb, name)
+      ElMessage.success(`已导出 ${detailData.value.length} 条明细`)
+    } catch (e) {
+      console.error('导出失败:', e)
+      ElMessage.error('导出失败')
+    }
+  }
+
+  onMounted(async () => {
+    await getTreeData()
+    // 不自动触发数据加载;等用户点击左侧节点再加载
+  })
+  </script>
+
+  <style scoped>
+  .JKWTree-tree {
+    background-color: #fff;
+    padding: 10px;
+    margin-right: 10px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
+  }
+  .JKWTree-tree h3 {
+    font-size: 14px;
+    font-weight: 700;
+    margin: 8px 0;
+  }
+  .sub-title {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    padding: 4px 0;
+    font-size: 13px;
+    font-weight: 600;
+    color: #333;
+  }
+  .sub-title-info {
+    font-size: 12px;
+    font-weight: 400;
+    color: #888;
+  }
+  .range-label {
+    font-size: 13px;
+    color: #555;
+    margin-right: 12px;
+  }
+  :deep(.el-table__body tr.current-row) > td {
+    background: #ff80ff !important;
+  }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
+  :deep(.el-table td .cell) {
+    line-height: 22px !important;
+  }
+  .bt {
+    margin-left: 2px !important;
+    padding: 3px !important;
+    font-size: 12px;
+  }
+  .gva-table-box {
+    padding: 0px !important;
+  }
+  </style>

+ 77 - 48
src/view/DecisionSupport/MonthProductOutputRate.vue

@@ -6,8 +6,6 @@
             <!--          按钮部分-->
             <el-form ref="elSearchFormRef"   class="demo-form-inline" :rules="searchRule" >
               <el-form-item>
-                <!-- <el-input v-model="searchInfo" placeholder="搜索成品名称" @keyup.enter="onsearch" clearable style="width: 200px;margin: 5px"></el-input>
-                <el-button type="primary" class="bt" icon="search" @click="onsearch">查询</el-button> -->
                 <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
                 <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button>
               </el-form-item>
@@ -21,9 +19,9 @@
         <layout>
           <!--    左侧树侧形结构-->
           <layout-sider :resize-directions="['right']" :width="210" style="margin-right: 10px;">
-            <div class="JKWTree-tree" style="height: 200px">
+            <div class="JKWTree-tree">
               <h3>产品月度投入产出率统计</h3>
-              <el-tree :data="treeData"  :props="defaultProps" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
+              <el-tree :data="treeData"  :props="defaultProps" node-key="key" highlight-current @node-click="handleNodeClick" @node-expand="handleNodeExpand">
               </el-tree>
             </div>
           </layout-sider>
@@ -45,13 +43,13 @@
                         @selection-change="handleSelectionChange">
                <el-table-column   align="center" label="成品代号" prop="成品编码"  width="120" />
                <el-table-column   align="center" label="印件代号" prop="印件代号"  width="100" />
-               <el-table-column   align="center" label="印件名称" prop="印件名称"  width="300" />
+               <el-table-column   align="center" label="印件名称" prop="印件名称"  width="320" />
                <el-table-column   align="center" label="订单数量" prop="订单数量"  width="90" />
                <el-table-column   align="center" label="实际投料" prop="实际投料"  width="120" />
                <el-table-column   align="center" label="入仓数量" prop="入仓数量"  width="110" />
                <el-table-column   align="center" label="投入产出率" prop="投入产出率"  width="110" />
                <el-table-column   align="center" label="客户编号" prop="客户编号"  width="110" />
-               <el-table-column   align="center" label="客户名称" prop="客户名称"  width="110" />
+               <el-table-column   align="center" label="客户名称" prop="客户名称"  width="200" />
               </el-table>
   
               <!-- 分页 -->
@@ -80,7 +78,7 @@
                <el-table-column   align="center" label="完工时间" prop="完工时间"  width="120" />
                <el-table-column   align="center" label="投入产出率" prop="投入产出率"  width="130" />
                <el-table-column   align="center" label="客户编号" prop="客户编号"  width="120" />
-               <el-table-column   align="center" label="客户名称" prop="客户名称"  width="120" />
+               <el-table-column   align="center" label="客户名称" prop="客户名称"  width="180" />
               </el-table>
             </div>
           </el-main>
@@ -98,10 +96,11 @@
   import * as XLSX from 'xlsx'
 import FileSaver from 'file-saver'
 import LuckyExcel from 'luckyexcel';
-  import {Productyearleft,Productyearlist,Productmonthlist,} from "@/api/mes/job.js"
+  import {Productmonthleft,Productmonthlist_hz,Productmonthlist_mx,} from "@/api/mes/job.js"
 
   defineOptions({name: 'Company'})
   // =========== 获取左侧树侧形结构 ===========
+  // 结构:工单类型 -> 年份 -> 年月(YYYYMM) -> 客户(客户编号【客户名称】)
 const treeData = ref([]);
 const defaultProps = {
   children: 'children',
@@ -109,39 +108,49 @@ const defaultProps = {
 };
 const getTreeData = async () => {
   try {
-    const res = await Productyearleft(); 
+    const res = await Productmonthleft(); // 调用月度左侧菜单接口
     if (res.code === 0 && res.data) {
-      // 转换数据结构
       treeData.value = Object.entries(res.data).map(([workshopType, yearsData]) => {
-        // 创建父节点(工单类型)
+        // 第一层:工单类型(翌星工单 / MN工单)
         const parentNode = {
           label: workshopType,
           value: workshopType,
           children: []
         };
-        
-        // 处理每个年份的数据
-        Object.entries(yearsData).forEach(([year, workshops]) => {
-          // 创建年份节点
+
+        // 第二层:年份
+        Object.entries(yearsData).forEach(([year, monthsData]) => {
           const yearNode = {
             label: year,
             value: `${workshopType}-${year}`,
-            children: workshops.map(workshop => ({
-              label: workshop.trim(),
-              value: `${workshopType}-${year}-${workshop.trim()}`,
-              type: 'workshop'
-            }))
+            children: []
           };
-          
+
+          // 第三层:年月(YYYYMM)
+          Object.entries(monthsData).forEach(([ym, customers]) => {
+            const monthNode = {
+              label: ym,
+              value: `${workshopType}-${year}-${ym}`,
+              children: customers.map(customer => ({
+                label: customer.trim(),
+                value: `${workshopType}-${year}-${ym}-${customer.trim()}`,
+                type: 'customer'
+              }))
+            };
+            yearNode.children.push(monthNode);
+          });
+
+          // 年月倒序
+          yearNode.children.sort((a, b) => b.label.localeCompare(a.label));
           parentNode.children.push(yearNode);
         });
-        
-        // 对年份节点按年份倒序排序
+
+        // 年份倒序
         parentNode.children.sort((a, b) => b.label.localeCompare(a.label));
-        
+
         return parentNode;
       });
-      
+
       console.log('生成的树形数据:', treeData.value);
     } else {
       console.error('获取数据失败:', res.msg);
@@ -152,34 +161,42 @@ const getTreeData = async () => {
 };
 getTreeData();
 
-const searchInfo = ref('')
+// 当前选中的年月(YYYYMM)
 const _noderq = ref('')
-const onsearch = async () => {
-  _noderq.value = treeData.value[0].children[0].label
-  if(searchInfo.value){
-    const res = await Productyearlist({search:searchInfo.value,rq:_noderq.value})
-
-    hztableData.value = res.data
-  }
-}
-
 
 const hztableData = ref([])
+// 点击左侧树:年份节点(2段) -> 年月节点(3段) -> 客户节点(4段及以上)
 const handleNodeClick = async (nodeData) => {
-  if(!nodeData.children){
-    _noderq.value = nodeData.value.split('-')[1]
-    const res = await Productyearlist({khdh:nodeData.value.split('-')[2].split('【')[0],rq:nodeData.value.split('-')[1]})
-    mxtableData.value = []
-    hztableData.value = res.data
+  const parts = String(nodeData.value).split('-')
+  if (parts.length < 3) {
+    // 工单类型 / 年份节点,不查询
+    return
+  }
 
+  const year = parts[1]
+  const ym = parts[2]
+  const params = { rq: year, ym: ym }
+
+  if (parts.length >= 4) {
+    // 客户节点:value = 工单类型-年份-年月-客户编号【客户名称】
+    const customer = parts.slice(3).join('-')
+    params.khdh = customer.split('【')[0]
   }
+
+  _noderq.value = ym
+  const res = await Productmonthlist_hz(params)
+  mxtableData.value = []
+  hztableData.value = res.data || []
 };
 
 const mxtableData = ref([])
-const hztableRowClick =  async (row, event, column) => {
-  console.log('点击了行:', row,);
-  const res = await Productmonthlist({product_code:row.成品编码,year:_noderq.value})
-  mxtableData.value = res.data
+// 点击上方汇总表行 -> 加载该成品的月度明细
+const hztableRowClick = async (row) => {
+  if (!row || !row.成品编码 || !_noderq.value) {
+    return
+  }
+  const res = await Productmonthlist_mx({ product_code: row.成品编码, ym: _noderq.value })
+  mxtableData.value = res.data || []
 };
 
 
@@ -212,7 +229,7 @@ const hzToExcel = async () => {
     // 创建并导出工作簿
     const workbook = XLSX.utils.book_new();
     XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
-    XLSX.writeFile(workbook, '年度产出率汇总.xlsx');
+    XLSX.writeFile(workbook, '月度产出率汇总.xlsx');
     
   } catch (error) {
     console.error('导出失败:', error);
@@ -228,7 +245,7 @@ const mxToExcel = async () => {
     const worksheet = XLSX.utils.table_to_sheet(el, { raw: true });
     
     // 指定需要转换为数字的列索引(0-based索引)
-    const numericColumns = [1, 2, 4]; 
+    const numericColumns = [1, 2, 3, 4, 5, 6, 7]; 
     
     // 获取工作表范围
     const range = XLSX.utils.decode_range(worksheet['!ref']);
@@ -253,7 +270,7 @@ const mxToExcel = async () => {
     // 创建并导出工作簿
     const workbook = XLSX.utils.book_new();
     XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
-    XLSX.writeFile(workbook, '年度产出率明细.xlsx');
+    XLSX.writeFile(workbook, '月度产出率明细.xlsx');
     
   } catch (error) {
     console.error('导出失败:', error);
@@ -262,6 +279,7 @@ const mxToExcel = async () => {
 };
   
 
+
   
   
   
@@ -312,6 +330,9 @@ const mxToExcel = async () => {
     background-color: #fff;
     padding: 10px;
     margin-right: 20px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
   }
   .JKWTree-tree h3 {
     font-size: 15px;
@@ -327,6 +348,15 @@ const mxToExcel = async () => {
   :deep(.el-table__body tr.current-row) > td {
     background: #ff80ff !important;
   }
+  /* 树节点字号 */
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
   </style>
   <style scoped>
   :deep(.el-table td .cell) {
@@ -354,4 +384,3 @@ const mxToExcel = async () => {
     margin-bottom: 5px;
   }
   </style>
-  

+ 26 - 34
src/view/DecisionSupport/Monthlyplatescrap.vue

@@ -20,9 +20,9 @@
         <layout>
           <!--    左侧树侧形结构-->
           <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
-            <div class="JKWTree-tree" style="height: 200px">
+            <div class="JKWTree-tree">
               <h3>月度印版报废</h3>
-              <el-tree :data="treeData"  :props="defaultProps" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
+              <el-tree :data="treeData"  :props="defaultProps" node-key="value" highlight-current @node-click="handleNodeClick" @node-expand="handleNodeExpand">
               </el-tree>
             </div>
           </layout-sider>
@@ -107,39 +107,20 @@ const GetTreeData = async () => {
   const res = await getPrintDateList({})
   if (res.code === 0) {
     const { data } = res
-    const transformedData = []
+    // 接口返回数组:[{year, months:[{month, days:[...]}]}, ...]
+    const transformedData = (data || []).map(yearItem => ({
+      label: `${yearItem.year}年`,
+      value: yearItem.year,
+      children: (yearItem.months || []).map(monthItem => ({
+        label: `${String(monthItem.month).split('-')[1]}月`,
+        value: monthItem.month,
+        children: (monthItem.days || []).map(date => ({
+          label: date,
+          value: date
+        }))
+      }))
+    }))
 
-    // 遍历年份
-    for (const [year, months] of Object.entries(data)) {
-      const yearNode = {
-        label: `${year}年`,
-        value: year,
-        children: []
-      }
-
-      // 遍历月份
-      for (const [month, dates] of Object.entries(months)) {
-        const monthNode = {
-          label: `${month.split('-')[1]}月`,
-          value: month,
-          children: []
-        }
-
-        // 遍历日期
-        dates.forEach(date => {
-          const dateNode = {
-            label: date,
-            value: date
-          }
-          monthNode.children.push(dateNode)
-        })
-
-        yearNode.children.push(monthNode)
-      }
-
-      transformedData.push(yearNode)
-    }
-    
     treeData.value = transformedData
   }
 }
@@ -217,12 +198,23 @@ const handleNodeClick = async (node) => {
     background-color: #fff;
     padding: 10px;
     margin-right: 20px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
   }
   .JKWTree-tree h3 {
     font-size: 15px;
     font-weight: 700;
     margin: 10px 0;
   }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
   .JKWTree-content {
     flex: 1;
   }

+ 38 - 15
src/view/DecisionSupport/ProductOutputRate.vue

@@ -23,7 +23,7 @@
           <layout-sider :resize-directions="['right']" :width="210" style="margin-right: 10px;">
             <div class="JKWTree-tree" style="height: 200px">
               <h3>产品年度投入产出率统计</h3>
-              <el-tree :data="treeData"  :props="defaultProps" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
+              <el-tree :data="treeData"  :props="defaultProps" node-key="value" highlight-current @node-click="handleNodeClick" @node-expand="handleNodeExpand">
               </el-tree>
             </div>
           </layout-sider>
@@ -162,20 +162,36 @@ const getTreeData = async () => {
 getTreeData();
 
 const searchInfo = ref('')
-const _noderq = ref('')
+const _noderq = ref('')   // 当前选中节点的年份
+const _nodekhdh = ref('') // 当前选中节点的客户代号(叶子节点)
+//查询:必须先点击左侧年份节点;有选中客户节点则带上客户条件
 const onsearch = async () => {
-  _noderq.value = treeData.value[0].children[0].label
-  if(searchInfo.value){
-    const res = await Productyearlist({search:searchInfo.value,rq:_noderq.value})
-
-    hztableData.value = res.data
+  if (!_noderq.value) {
+    ElMessage.warning('请先点击左侧年份节点')
+    return
+  }
+  const params = { rq: _noderq.value }
+  if (searchInfo.value.trim()) params.search = searchInfo.value.trim()
+  if (_nodekhdh.value) params.khdh = _nodekhdh.value
+  try {
+    const res = await Productyearlist(params)
+    if (res.code === 0) {
+      hztableData.value = res.data || []
+      mxtableData.value = []
+      if (!hztableData.value.length) {
+        ElMessage.warning('未查询到数据')
+      }
+    }
+  } catch (error) {
+    console.error('查询出错:', error)
+    ElMessage.error('查询失败')
   }
 }
 
 
 const hztableData = ref([])
-const handleNodeClick = async (nodeData) => {
-  const nodeValue = nodeData.value 
+const handleNodeClick = async (node) => {
+  const nodeValue = node.value
   const parts = nodeValue.split('-') // 分割节点值
   if (parts.length === 1) {
     // 点击翌星or美浓节点
@@ -184,8 +200,9 @@ const handleNodeClick = async (nodeData) => {
 
   // 第二层:分类节点 (如 "202410-2、水电气直接费用")
   if (parts.length === 2) {
-    _noderq.value = nodeData.value.split('-')[1]
-    const res = await Productyearlist({rq:nodeData.value.split('-')[1]})
+    _noderq.value = node.value.split('-')[1]
+    _nodekhdh.value = ''
+    const res = await Productyearlist({rq:node.value.split('-')[1]})
     mxtableData.value = []
     hztableData.value = res.data
     return;
@@ -195,9 +212,10 @@ const handleNodeClick = async (nodeData) => {
   if (parts.length === 3) {
   }
 
-  if(!nodeData.children){
-    _noderq.value = nodeData.value.split('-')[1]
-    const res = await Productyearlist({khdh:nodeData.value.split('-')[2].split('【')[0],rq:nodeData.value.split('-')[1]})
+  if(!node.children){
+    _noderq.value = node.value.split('-')[1]
+    _nodekhdh.value = node.value.split('-')[2].split('【')[0]
+    const res = await Productyearlist({khdh:_nodekhdh.value,rq:_noderq.value})
     mxtableData.value = []
     hztableData.value = res.data
 
@@ -257,7 +275,7 @@ const mxToExcel = async () => {
     const worksheet = XLSX.utils.table_to_sheet(el, { raw: true });
     
     // 指定需要转换为数字的列索引(0-based索引)
-    const numericColumns = [1, 2, 4]; 
+    const numericColumns = [2, 3, 5, 6]; 
     
     // 获取工作表范围
     const range = XLSX.utils.decode_range(worksheet['!ref']);
@@ -382,5 +400,10 @@ const mxToExcel = async () => {
   .mab{
     margin-bottom: 5px;
   }
+  /* 选中的树节点文字变红 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
   </style>
   

+ 333 - 0
src/view/DecisionSupport/YearManualinspectionStatistics.vue

@@ -0,0 +1,333 @@
+<template>
+    <div>
+      <layout>
+        <layout-header>
+          <div class="">
+            <el-form ref="elSearchFormRef" class="demo-form-inline">
+              <el-form-item>
+                <el-input v-model="searchInfo" placeholder="产品编号 / 产品名称" clearable
+                          style="width: 200px;margin: 5px" @keyup.enter="onsearch"></el-input>
+                <el-button type="primary" class="bt" icon="search" @click="onsearch">查询</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="exportSummary">导出汇总</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="exportDetail">导出明细</el-button>
+              </el-form-item>
+            </el-form>
+          </div>
+        </layout-header>
+
+        <layout>
+          <layout-sider :resize-directions="['right']" :width="230" style="margin-right: 10px;">
+            <div class="JKWTree-tree">
+              <h3>年度手工检验统计</h3>
+              <el-tree ref="treeRef" :data="treeData" :props="defaultProps" node-key="key"
+                       highlight-current @node-click="handleNodeClick">
+              </el-tree>
+            </div>
+          </layout-sider>
+
+          <layout-content>
+          <el-main>
+            <div class="gva-table-box">
+              <el-table id="sgyjsummarytable" ref="summaryTableRef" style="width: 100%;height: 40vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="summaryData" border size="small"
+                        :span-method="spanMethod" :row-class-name="rowClassName"
+                        highlight-current-row="true" :show-overflow-tooltip="true"
+                        @row-click="handleSummaryRowClick">
+                <el-table-column align="center" label="产品编号" prop="产品编号" width="120" />
+                <el-table-column align="center" label="产品名称" prop="产品名称" min-width="360" />
+                <el-table-column align="center" label="产品类别" prop="产品类别" width="90" />
+                <el-table-column align="center" label="总产量(大箱)" prop="每月合计" width="110" />
+                <el-table-column v-for="item in monthCols" :key="item.prop" align="center"
+                                 :label="item.label" :prop="item.prop" width="75" />
+                <el-table-column align="center" label="客户编号" prop="客户编号" width="100" />
+                <el-table-column align="center" label="客户名称" prop="客户名称" width="180" />
+              </el-table>
+            </div>
+
+            <div class="gva-table-box" style="margin-top: 10px;">
+              <el-table id="sgyjdetailtable" ref="detailTableRef" style="width: 100%;height: 32vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="detailData" border size="small"
+                        highlight-current-row="true" :show-overflow-tooltip="true">
+                <el-table-column align="center" label="年月" prop="年月" width="80" />
+                <el-table-column align="center" label="工单编号" prop="工单编号" width="110" />
+                <el-table-column align="center" label="产品编号" prop="产品编号" width="120" />
+                <el-table-column align="center" label="产品名称" prop="产品名称" min-width="300" />
+                <el-table-column align="center" label="产品类别" prop="产品类别" width="90" />
+                <el-table-column align="center" label="总产量(大箱)" prop="总产量" width="110" />
+                <el-table-column align="center" label="客户编号" prop="客户编号" width="100" />
+                <el-table-column align="center" label="客户名称" prop="客户名称" width="180" />
+              </el-table>
+            </div>
+          </el-main>
+        </layout-content>
+        </layout>
+      </layout>
+    </div>
+  </template>
+
+  <script setup>
+  import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue';
+
+  import { ref } from 'vue'
+  import { ElMessage } from "element-plus";
+  import * as XLSX from 'xlsx'
+  import { YearSgyjLeft, YearSgyjList } from "@/api/DecisionSupport/decision.js"
+
+  defineOptions({name: 'YearManualinspectionStatistics'})
+
+  const treeRef = ref(null)
+  const summaryTableRef = ref(null)
+  const detailTableRef = ref(null)
+  const treeData = ref([])
+  const defaultProps = {
+    children: 'children',
+    label: 'label'
+  }
+  const currentYear = ref('')
+  const currentCustomer = ref('')
+
+  const summaryData = ref([])
+  const detailData = ref([])
+  // 当前条件下的全部明细,点击上方汇总行后按产品编号显示到下方表格
+  const allDetailData = ref([])
+  const searchInfo = ref('')
+  let requestId = 0
+
+  const monthCols = Array.from({ length: 12 }, (_, i) => {
+    const month = String(i + 1).padStart(2, '0')
+    return { label: `${month}月`, prop: `${month}月` }
+  })
+
+  const getTreeData = async () => {
+    try {
+      const res = await YearSgyjLeft()
+      if (res.code === 0 && Array.isArray(res.data)) {
+        treeData.value = res.data.map(yearItem => ({
+          label: String(yearItem.年份),
+          key: `Y${yearItem.年份}`,
+          year: String(yearItem.年份),
+          children: (yearItem.客户 || []).map(customerItem => ({
+            label: [customerItem.客户编号, customerItem.客户名称].filter(Boolean).join(' '),
+            key: `Y${yearItem.年份}-C${customerItem.客户编号 || customerItem.客户名称}`,
+            year: String(yearItem.年份),
+            customer: customerItem.客户编号 || ''
+          }))
+        }))
+        // 进入页面只加载左侧树,不自动聚焦、不自动查询
+      } else {
+        console.error('获取数据失败:', res.msg)
+      }
+    } catch (error) {
+      console.error('请求出错:', error)
+    }
+  }
+  getTreeData()
+
+  const handleNodeClick = (nodeData) => {
+    if (!nodeData || !nodeData.year) {
+      return
+    }
+    currentYear.value = nodeData.year
+    currentCustomer.value = nodeData.customer || ''
+    fetchData()
+  }
+
+  // 点击年份节点才查询汇总(含全量明细),明细按产品编号筛选后显示在下方
+  const fetchData = async () => {
+    if (!currentYear.value) {
+      ElMessage.warning('请先在左侧选择年份')
+      return
+    }
+    const id = ++requestId
+    summaryData.value = []
+    detailData.value = []
+    allDetailData.value = []
+    try {
+      const res = await YearSgyjList({
+        year: currentYear.value,
+        customer: currentCustomer.value,
+        search: searchInfo.value
+      })
+      if (id !== requestId) {
+        return
+      }
+      const data = res.data || {}
+      summaryData.value = data.summary || []
+      allDetailData.value = data.detail || []
+    } catch (error) {
+      if (id !== requestId) {
+        return
+      }
+      console.error('请求出错:', error)
+    }
+  }
+
+  // 点击上方汇总行才显示该产品的明细到下方表格
+  const handleSummaryRowClick = (row) => {
+    if (!row || row.合计类型 || !row.产品编号) {
+      detailData.value = []
+      return
+    }
+    const cpbh = String(row.产品编号).trim()
+    detailData.value = allDetailData.value.filter(item => String(item.产品编号 || '').trim() === cpbh)
+  }
+
+  const onsearch = () => {
+    if (!currentYear.value) {
+      ElMessage.warning('请先在左侧选择年份')
+      return
+    }
+    fetchData()
+  }
+
+  const spanMethod = ({ row, columnIndex }) => {
+    if (!row.合计类型) {
+      return
+    }
+    if (columnIndex === 0) {
+      return { rowspan: 1, colspan: 3 }
+    }
+    if (columnIndex === 1 || columnIndex === 2) {
+      return { rowspan: 0, colspan: 0 }
+    }
+  }
+
+  const rowClassName = ({ row }) => {
+    if (!row.合计类型) {
+      return ''
+    }
+    // 多个合计行:倒数第 N 个合计行 -> total-row-sticky-N
+    const totalRows = summaryData.value.filter(r => r.合计类型)
+    const totalCount = totalRows.length
+    const idx = totalRows.findIndex(r => r === row)
+    const offset = totalCount - idx
+    return `total-row total-row-sticky-${offset}`
+  }
+
+  // 仅导出上方汇总表
+  const exportSummary = () => {
+    if (!summaryData.value.length) {
+      ElMessage.warning('暂无汇总数据可导出')
+      return
+    }
+    try {
+      const workbook = XLSX.utils.book_new()
+      const summaryEl = document.getElementById('sgyjsummarytable')
+      const summarySheet = XLSX.utils.table_to_sheet(summaryEl, { raw: true })
+      XLSX.utils.book_append_sheet(workbook, summarySheet, '汇总')
+      XLSX.writeFile(workbook, `年度手工检验统计_汇总_${currentYear.value}.xlsx`)
+    } catch (error) {
+      console.error('导出失败:', error)
+      ElMessage.error('导出汇总数据失败,请重试')
+    }
+  }
+
+  // 仅导出下方明细表(全量明细 allDetailData,避免只导出当前筛选可见的几行)
+  const exportDetail = () => {
+    if (!allDetailData.value.length) {
+      ElMessage.warning('暂无明细数据可导出')
+      return
+    }
+    try {
+      const workbook = XLSX.utils.book_new()
+      const header = ['年月', '工单编号', '产品编号', '产品名称', '产品类别', '总产量(大箱)', '客户编号', '客户名称']
+      const rows = allDetailData.value.map(row => header.map(col => (row[col] === undefined || row[col] === null ? '' : row[col])))
+      const detailSheet = XLSX.utils.aoa_to_sheet([header, ...rows])
+      XLSX.utils.book_append_sheet(workbook, detailSheet, '工单明细')
+      XLSX.writeFile(workbook, `年度手工检验统计_明细_${currentYear.value}.xlsx`)
+    } catch (error) {
+      console.error('导出失败:', error)
+      ElMessage.error('导出明细数据失败,请重试')
+    }
+  }
+
+  </script>
+
+  <style scoped>
+  .form-container {
+    display: flex;
+    flex-wrap: wrap;
+  }
+
+  .form-column {
+    margin-right: 15px;
+  }
+
+  .form-column .el-form-item .el-input {
+    width: 150px;
+  }
+
+  @media screen and (max-width: 768px) {
+    .form-column {
+      flex: 1 0 100%;
+      margin-right: 0;
+    }
+  }
+
+  .JKWTree-tree {
+    background-color: #fff;
+    padding: 10px;
+    margin-right: 20px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
+  }
+
+  .JKWTree-tree h3 {
+    font-size: 15px;
+    font-weight: 700;
+    margin: 10px 0;
+  }
+
+  :deep(.el-table__body tr.current-row) > td {
+    background: #ff80ff !important;
+  }
+
+  :deep(.el-table__body tr.total-row) > td {
+    background: #ffff00 !important;
+  }
+
+  /* 所有合计行都 sticky 冻结在表格底部,按 bottom 值层层叠放 */
+  :deep(.el-table__body tr.total-row) {
+    position: sticky;
+    z-index: 3;
+  }
+  /* 倒数第 1 个合计行 bottom:0 */
+  :deep(.el-table__body tr.total-row-sticky-1) {
+    bottom: 0;
+  }
+  /* 倒数第 2 个合计行 bottom:25px(行高 25px) */
+  :deep(.el-table__body tr.total-row-sticky-2) {
+    bottom: 25px;
+  }
+
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
+  </style>
+
+  <style scoped>
+  :deep(.el-table td .cell) {
+    line-height: 20px !important;
+  }
+
+  .bt {
+    margin-left: 2px !important;
+    padding: 3px !important;
+    font-size: 12px;
+  }
+
+  .gva-table-box {
+    padding: 0px !important;
+  }
+  </style>

+ 290 - 0
src/view/DecisionSupport/Yearcprctj.vue

@@ -0,0 +1,290 @@
+<template>
+    <div>
+      <layout>
+        <layout-header>
+          <div class="">
+            <!--          按钮部分-->
+            <el-form ref="elSearchFormRef" class="demo-form-inline">
+              <el-form-item>
+                <el-input v-model="searchInfo" placeholder="产品编号 / 产品名称" clearable
+                          style="width: 200px;margin: 5px" @keyup.enter="onsearch"></el-input>
+                <el-button type="primary" class="bt" icon="search" @click="onsearch">查询</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="exportExcel">导出到Excel</el-button>
+              </el-form-item>
+            </el-form>
+          </div>
+        </layout-header>
+
+        <layout>
+          <!--    左侧树侧形结构:年 -> 客户-->
+          <layout-sider :resize-directions="['right']" :width="230" style="margin-right: 10px;">
+            <div class="JKWTree-tree">
+              <h3>年度成品入仓统计</h3>
+              <el-tree ref="treeRef" :data="treeData" :props="defaultProps" node-key="key"
+                       highlight-current @node-click="handleNodeClick">
+              </el-tree>
+            </div>
+          </layout-sider>
+
+          <!-- 右侧区域 -->
+          <layout-content>
+          <el-main>
+            <div class="gva-table-box">
+              <el-table id="yeartable" ref="tableRef" style="width: 100%;height: 72vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="tableData" border
+                        size="small"
+                        :span-method="spanMethod" :row-class-name="rowClassName"
+                        highlight-current-row="true" :show-overflow-tooltip="true">
+               <el-table-column align="center" label="产品编号" prop="产品编号" width="120" />
+               <el-table-column align="center" label="产品名称" prop="产品名称" min-width="360" />
+               <el-table-column align="center" label="产品类别" prop="产品类别" width="90" />
+               <el-table-column align="center" label="每月合计(大箱)" prop="每月合计" width="120" />
+               <el-table-column v-for="item in monthCols" :key="item.prop" align="center"
+                                :label="item.label" :prop="item.prop" width="75" />
+               <el-table-column align="center" label="客户编号" prop="客户编号" width="100" />
+               <el-table-column align="center" label="客户名称" prop="客户名称" width="180" />
+              </el-table>
+            </div>
+          </el-main>
+        </layout-content>
+        </layout>
+      </layout>
+    </div>
+  </template>
+  <script setup>
+  // 全量引入格式化工具 请按需保留
+  import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
+
+  import {ref, nextTick} from 'vue'
+  import {ElMessage} from "element-plus";
+  import * as XLSX from 'xlsx'
+  import { YearcprctjLeft, YearcprctjList } from "@/api/DecisionSupport/decision.js"
+
+  defineOptions({name: 'Company'})
+
+  const treeRef = ref(null)
+  const tableRef = ref(null)
+  const treeData = ref([])
+  const defaultProps = {
+    children: 'children',
+    label: 'label'
+  }
+  // 当前选中的年份、客户
+  const currentYear = ref('')
+  const currentCustomer = ref('')
+
+  const tableData = ref([])
+  const searchInfo = ref('')
+  // 防止快速切换时旧请求覆盖新数据
+  let requestId = 0
+
+  // 月份列 01月 ~ 12月
+  const monthCols = Array.from({ length: 12 }, (_, i) => {
+    const month = String(i + 1).padStart(2, '0')
+    return { label: `${month}月`, prop: `${month}月` }
+  })
+
+  // =========== 左侧树:年 -> 客户 ===========
+  const getTreeData = async () => {
+    try {
+      const res = await YearcprctjLeft()
+      if (res.code === 0 && Array.isArray(res.data)) {
+        treeData.value = res.data.map(yearItem => ({
+          label: String(yearItem.年份),
+          key: `Y${yearItem.年份}`,
+          year: String(yearItem.年份),
+          children: (yearItem.客户 || []).map(customerItem => ({
+            label: [customerItem.客户编号, customerItem.客户名称].filter(Boolean).join(' '),
+            key: `Y${yearItem.年份}-C${customerItem.客户编号}`,
+            year: String(yearItem.年份),
+            customer: customerItem.客户编号 || ''
+          }))
+        }))
+
+        // 只加载树数据;不自动聚焦/查询,等用户点击节点后再加载
+        // 默认不设 currentYear / currentCustomer,避免自动触发 fetchData
+      } else {
+        console.error('获取数据失败:', res.msg)
+      }
+    } catch (error) {
+      console.error('请求出错:', error)
+    }
+  }
+  getTreeData()
+
+  // 点击年份节点查询全年,点击客户节点查询该客户
+  const handleNodeClick = (nodeData) => {
+    if (!nodeData || !nodeData.year) {
+      return
+    }
+    currentYear.value = nodeData.year
+    currentCustomer.value = nodeData.customer || ''
+    fetchData()
+  }
+
+  const fetchData = async () => {
+    if (!currentYear.value) {
+      ElMessage.warning('请先在左侧选择年份')
+      return
+    }
+    const id = ++requestId
+    tableData.value = []
+    try {
+      const res = await YearcprctjList({
+        year: currentYear.value,
+        customer: currentCustomer.value,
+        search: searchInfo.value
+      })
+      if (id !== requestId) {
+        return
+      }
+      tableData.value = res.data || []
+    } catch (error) {
+      if (id !== requestId) {
+        return
+      }
+      console.error('请求出错:', error)
+      tableData.value = []
+    }
+  }
+
+  // 资料筛选:按产品编号/产品名称模糊搜索
+  const onsearch = () => {
+    fetchData()
+  }
+
+  // 合计行合并前3列(产品编号、产品名称、产品类别),并加黄色背景
+  const spanMethod = ({ row, columnIndex }) => {
+    if (!row.合计类型) {
+      return
+    }
+    if (columnIndex === 0) {
+      return { rowspan: 1, colspan: 3 }
+    }
+    if (columnIndex === 1 || columnIndex === 2) {
+      return { rowspan: 0, colspan: 0 }
+    }
+  }
+
+  const rowClassName = ({ row }) => (row.合计类型 ? 'total-row' : '')
+
+  // 导出右侧表格全部数据
+  const exportExcel = () => {
+    if (!tableData.value.length) {
+      ElMessage.warning('暂无数据可导出')
+      return
+    }
+    try {
+      const el = document.getElementById('yeartable')
+      const worksheet = XLSX.utils.table_to_sheet(el, { raw: true })
+
+      // 每月合计(第4列)及01月~12月(第5~16列)转为数字格式
+      const range = XLSX.utils.decode_range(worksheet['!ref'])
+      for (let col = 3; col <= 15; col++) {
+        for (let row = range.s.r + 1; row <= range.e.r; row++) {
+          const cellAddress = XLSX.utils.encode_cell({ r: row, c: col })
+          const cell = worksheet[cellAddress]
+          if (cell && cell.v !== '') {
+            const numValue = Number(cell.v)
+            if (!isNaN(numValue)) {
+              cell.t = 'n'
+              cell.v = numValue
+            }
+          }
+        }
+      }
+
+      const workbook = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
+      XLSX.writeFile(workbook, `年度成品入仓统计_${currentYear.value}.xlsx`)
+    } catch (error) {
+      console.error('导出失败:', error)
+      ElMessage.error('导出数据失败,请重试')
+    }
+  }
+
+  </script>
+
+  <style scoped>
+  .form-container {
+    display: flex;
+    flex-wrap: wrap;
+  }
+
+  .form-column {
+    /*flex: 1;*/
+    margin-right: 15px; /* 调整列之间的间距 */
+  }
+
+  /* 左侧输入框宽度调整 */
+  .form-column .el-form-item .el-input {
+    width: 150px; /* 调整左侧输入框的宽度 */
+  }
+
+  /* 媒体查询,根据需要调整断点 */
+  @media screen and (max-width: 768px) {
+    .form-column {
+      flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
+      margin-right: 0;
+    }
+  }
+
+  .JKWTree-container {
+    display: flex;
+  }
+  .JKWTree-tree {
+    background-color: #fff;
+    padding: 10px;
+    margin-right: 20px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
+  }
+  .JKWTree-tree h3 {
+    font-size: 15px;
+    font-weight: 700;
+    margin: 10px 0;
+  }
+  .JKWTree-content {
+    flex: 1;
+  }
+
+  /* 选中某行时的背景色 */
+  :deep(.el-table__body tr.current-row) > td {
+    background: #ff80ff !important;
+  }
+  /* 小盒合计、条盒合计行背景色 */
+  :deep(.el-table__body tr.total-row) > td {
+    background: #ffff00 !important;
+  }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
+  </style>
+  <style scoped>
+  :deep(.el-table td .cell) {
+    line-height: 20px !important;
+  }
+  .el-tabs__header{
+    margin-bottom: 0;
+  }
+  .bt{
+    margin-left: 2px !important;
+    padding: 3px !important;
+    font-size: 12px;
+  }
+  .el-tabs__header{
+    margin: 0px !important;
+  }
+  .gva-table-box{
+    padding: 0px !important;
+  }
+  </style>

+ 308 - 0
src/view/DecisionSupport/cprctj.vue

@@ -0,0 +1,308 @@
+<template>
+    <div>
+      <layout>
+        <layout-header>
+          <div class="">
+            <!--          按钮部分-->
+            <el-form ref="elSearchFormRef"   class="demo-form-inline" >
+              <el-form-item>
+                <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button>
+                <!-- <el-button type="primary" class="bt" icon="download" disabled >月度统计导出</el-button>
+                <el-button type="primary" class="bt" icon="download" disabled >月度产值导出</el-button> -->
+              </el-form-item>
+            </el-form>
+
+          </div>
+        </layout-header>
+
+        <layout>
+          <!--    左侧树侧形结构-->
+          <layout-sider :resize-directions="['right']" :width="260" style="margin-right: 10px;">
+            <div class="JKWTree-tree">
+              <h3>组合汇总</h3>
+              <el-tree :data="treeData"  :props="defaultProps" node-key="key" highlight-current @node-click="handleNodeClick">
+              </el-tree>
+            </div>
+          </layout-sider>
+
+          <!-- 右侧区域 -->
+          <layout-content >
+          <el-main>
+            <div class="gva-table-box">
+              <!-- 上方表格:按日期汇总 -->
+              <el-table id="hztable" ref="hztableRef" style="width: 100%;height: 33vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="hztableData"  border
+                        size="small"
+                        highlight-current-row="true"
+                        @row-click="hztableRowClick" :show-overflow-tooltip="true">
+               <el-table-column  align="center" label="日期" prop="日期" width="130" :formatter="dateFormatter" />
+               <el-table-column  align="center" label="小盒入仓数" prop="小盒入仓数" width="150" />
+               <el-table-column  align="center" label="条盒入仓数" prop="条盒入仓数" width="150" />
+               <el-table-column  align="center" label="其他类" prop="其他类" width="150" />
+               <el-table-column  align="center" label="入仓数量" prop="入仓数量" width="150" />
+              </el-table>
+
+              <!-- 下方表格:工单+印件明细 -->
+              <el-table id="mxtable" ref="mxtableRef" style="width: 100%;height: 45vh" tooltip-effect="dark"
+                        :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :data="mxtableData"  border
+                        size="small"
+                        highlight-current-row="true" :show-overflow-tooltip="true">
+               <el-table-column  align="center" label="工单编号" prop="工单编号" width="110" />
+               <el-table-column  align="center" label="印件代号" prop="印件代号" width="120" />
+               <el-table-column  align="center" label="印件名称" prop="印件名称" width="320" />
+               <el-table-column  align="center" label="日期" prop="日期" width="110" :formatter="dateFormatter" />
+               <el-table-column  align="center" label="小盒数" prop="小盒数" width="110" />
+               <el-table-column  align="center" label="条盒数" prop="条盒数" width="110" />
+               <el-table-column  align="center" label="其他类" prop="其他类" width="110" />
+               <el-table-column  align="center" label="入仓数量" prop="入仓数量" width="110" />
+               <el-table-column  align="center" label="单位" prop="单位" width="80" />
+               <el-table-column  align="center" label="客户编号" prop="客户编号" width="110" />
+               <el-table-column  align="center" label="客户名称" prop="客户名称" width="200" />
+              </el-table>
+            </div>
+          </el-main>
+        </layout-content>
+        </layout>
+      </layout>
+    </div>
+  </template>
+  <script setup>
+  // 全量引入格式化工具 请按需保留
+  import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
+
+  import {ref} from 'vue'
+  import {ElMessage} from "element-plus";
+  import * as XLSX from 'xlsx'
+  import { CprctjLeft, CprctjList_hz, CprctjList_mx } from "@/api/DecisionSupport/decision.js"
+
+  defineOptions({name: 'Company'})
+
+  const treeData = ref([])
+  const defaultProps = {
+    children: 'children',
+    label: 'label'
+  }
+  // 当前选中的账期(YYYYMM 或 YYYY)
+  const _noderq = ref('')
+
+  // =========== 左侧树侧形结构:年 -> 年月 ===========
+  const getTreeData = async () => {
+    try {
+      const res = await CprctjLeft()
+      if (res.code === 0 && res.data) {
+        treeData.value = res.data.map(yearItem => ({
+          label: `${yearItem.年份} 【小盒:${Number(yearItem.小盒).toFixed(2)} 条盒:${Number(yearItem.条盒).toFixed(2)}】`,
+          ym: String(yearItem.年份),
+          children: (yearItem.月份 || []).map(monthItem => ({
+            label: `${monthItem.年月} 【小盒:${Number(monthItem.小盒).toFixed(3)} 条盒:${Number(monthItem.条盒).toFixed(3)}】`,
+            ym: String(monthItem.年月)
+          }))
+        }))
+      } else {
+        console.error('获取数据失败:', res.msg)
+      }
+    } catch (error) {
+      console.error('请求出错:', error)
+    }
+  }
+  getTreeData()
+
+  const hztableData = ref([])
+  const mxtableData = ref([])
+
+  // 日期显示为 YYYY.MM.DD
+  const dateFormatter = (row, column, cellValue) => {
+    return String(cellValue || '').replace(/-/g, '.')
+  }
+
+  // 点击左侧树:年份节点查全年,年月节点查当月
+  const handleNodeClick = async (nodeData) => {
+    if (!nodeData || !nodeData.ym) {
+      return
+    }
+    _noderq.value = nodeData.ym
+    hztableData.value = []
+    mxtableData.value = []
+
+    const hzRes = await CprctjList_hz({ ym: nodeData.ym })
+    hztableData.value = hzRes.data || []
+
+    const mxRes = await CprctjList_mx({ ym: nodeData.ym })
+    mxtableData.value = mxRes.data || []
+  }
+
+  // 点击上方表格行 -> 加载该日期的明细
+  const hztableRowClick = async (row) => {
+    if (!row || !row.日期 || !_noderq.value) {
+      return
+    }
+    const res = await CprctjList_mx({ ym: _noderq.value, date: row.日期 })
+    mxtableData.value = res.data || []
+  }
+
+  // 汇总导出
+  const hzToExcel = () => {
+    try {
+      const el = document.getElementById('hztable')
+      const worksheet = XLSX.utils.table_to_sheet(el, { raw: true })
+
+      // 从第2列开始转为数字格式
+      const range = XLSX.utils.decode_range(worksheet['!ref'])
+      for (let col = 1; col <= range.e.c; col++) {
+        for (let row = range.s.r + 1; row <= range.e.r; row++) {
+          const cellAddress = XLSX.utils.encode_cell({ r: row, c: col })
+          if (worksheet[cellAddress]) {
+            const numValue = Number(worksheet[cellAddress].v)
+            if (!isNaN(numValue)) {
+              worksheet[cellAddress].t = 'n'
+              worksheet[cellAddress].v = numValue
+            }
+          }
+        }
+      }
+
+      const workbook = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
+      XLSX.writeFile(workbook, '组合汇总.xlsx')
+    } catch (error) {
+      console.error('导出失败:', error)
+      ElMessage.error('导出数据失败,请重试')
+    }
+  }
+
+  // 明细导出
+  const mxToExcel = () => {
+    try {
+      const el = document.getElementById('mxtable')
+      const worksheet = XLSX.utils.table_to_sheet(el, { raw: true })
+
+      // 小盒数/条盒数/其他类/入仓数量 转数字
+      const numericColumns = [4, 5, 6, 7]
+      const range = XLSX.utils.decode_range(worksheet['!ref'])
+      numericColumns.forEach(colIndex => {
+        for (let row = range.s.r + 1; row <= range.e.r; row++) {
+          const cellAddress = XLSX.utils.encode_cell({ r: row, c: colIndex })
+          if (worksheet[cellAddress]) {
+            const cellValue = worksheet[cellAddress].v
+            const numValue = Number(cellValue)
+            if (!isNaN(numValue) && cellValue !== '') {
+              worksheet[cellAddress].t = 'n'
+              worksheet[cellAddress].v = numValue
+            }
+          }
+        }
+      })
+
+      const workbook = XLSX.utils.book_new()
+      XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
+      XLSX.writeFile(workbook, '组合汇总明细.xlsx')
+    } catch (error) {
+      console.error('导出失败:', error)
+      ElMessage.error('导出数据失败,请重试')
+    }
+  }
+
+  </script>
+
+  <style scoped>
+  .form-container {
+    display: flex;
+    flex-wrap: wrap;
+  }
+
+  .form-column {
+    /*flex: 1;*/
+    margin-right: 15px; /* 调整列之间的间距 */
+  }
+
+  /* 左侧输入框宽度调整 */
+  .form-column .el-form-item .el-input {
+    width: 150px; /* 调整左侧输入框的宽度 */
+  }
+
+  :deep(.hui-plan-usage-lows  div) {
+    color: #8c939d !important;
+  }
+  :deep(.lan-plan-usage-lows  div) {
+    color: blue !important;
+    font-weight: bold;
+  }
+
+
+  /* 媒体查询,根据需要调整断点 */
+  @media screen and (max-width: 768px) {
+    .form-column {
+      flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
+      margin-right: 0;
+    }
+  }
+  /*:deep(.el-table td .cell) {*/
+  /*  line-height: 30px !important;*/
+  /*}*/
+  .JKWTree-container {
+    display: flex;
+  }
+  .JKWTree-tree {
+    /*width: 300px;*/
+    background-color: #fff;
+    padding: 10px;
+    margin-right: 20px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
+  }
+  .JKWTree-tree h3 {
+    font-size: 15px;
+    font-weight: 700;
+    margin: 10px 0;
+  }
+  .JKWTree-content {
+    flex: 1;
+  }
+
+
+  /* 选中某行时的背景色 */
+  :deep(.el-table__body tr.current-row) > td {
+    background: #ff80ff !important;
+  }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
+  }
+  </style>
+  <style scoped>
+  :deep(.el-table td .cell) {
+    line-height: 20px !important;
+  }
+  :deep(.el-tabs__header){
+    margin-bottom: 0;
+  }
+  .search{
+    margin-left: 0px !important;
+    margin-right: 10px !important;
+  }
+  .bt{
+    margin-left: 2px !important;
+    padding: 3px !important;
+    font-size: 12px;
+  }
+  .el-tabs__header{
+    margin: 0px !important;
+  }
+  .gva-table-box{
+    padding: 0px !important;
+  }
+  .mab{
+    margin-bottom: 5px;
+  }
+  </style>

+ 86 - 63
src/view/DecisionSupport/productioncents/index.vue

@@ -16,10 +16,12 @@
   
         <layout>
           <!--    左侧树侧形结构-->
-          <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
-          <div class="JKWTree-tree" style="height: 200px">
-            <h3>年份</h3>
-            <el-tree :data="treeData" class="treecolor"   @node-click="handleNodeClick"></el-tree>
+          <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
+          <div class="JKWTree-tree">
+            <h3>生产中心统计</h3>
+            <el-tree :data="treeData" :props="defaultProps" node-key="key"
+                     highlight-current @node-click="handleNodeClick">
+            </el-tree>
           </div>
         </layout-sider>
   
@@ -132,7 +134,7 @@
   import * as echarts from 'echarts';
   import * as XLSX from 'xlsx';
   import FileSaver from 'file-saver';
-  import {ref, reactive,watchEffect} from 'vue';
+  import {ref, reactive, watchEffect, onMounted} from 'vue';
   import {GetYear,ProcessOutputRate,PoductData} from '@/api/mes/job'
   import {getCustom, getDepartment, getProductData,getStaffInfo, getStaffList, ygjbzledit,clockUpdate} from '@/api/yunyin/yunying';
   import {ElMessage} from "element-plus";
@@ -172,31 +174,45 @@ const cp_gdprintonClick = () => {
 
 
 
-  // =========== 获取左侧树侧形结构 ===========
-  
-  const AttendanceVisible=ref(false)
-  const _department_code = ref(null)
-// 树形控件的数据
+// 固定的 11 个报表类型(按用户提供的顺序)
+const REPORT_TYPES = [
+  { key: 'month_output',      label: '产量月统计报表' },
+  { key: 'month_schedule',    label: '排产达成率月统计' },
+  { key: 'month_workhour',    label: '工时达成率月统计报表' },
+  { key: 'month_oee',         label: 'OEE月统计报表' },
+  { key: 'month_changeover',  label: '换型效率月统计报表' },
+  { key: 'month_ioi',         label: '投入产出率月统计报表' },
+  { key: 'month_processrate', label: '工序产出率月统计报表' },
+  { key: 'year_equipment_waste', label: '年度设备编组废品统计' },
+  { key: 'year_equipment_box',   label: '年度设备大箱数统计' },
+  { key: 'day_output',        label: '产量日报表统计' },
+];
+
+const defaultProps = { children: 'children', label: 'label' };
+
+// =========== 获取左侧树侧形结构 ===========
 const treeData = ref([]);
-const getDepartmentdata = async () => {
+const loadTreeData = async () => {
   try {
     const data = await GetYear();
-    console.log(data);
-
-    // 将 data.data 转换为 el-tree 所需的结构,并从大到小排序
-    treeData.value = data.data
-      .map(year => ({
-        label: year.toString(), // 将年份转换为字符串
-        children: [] // 可以留空,或者根据需求添加子节点
-      }))
-      .sort((a, b) => b.label - a.label); // 从大到小排序
-
-    console.log(treeData.value); // 打印转换后的数据
+    const years = (data.data || []).sort((a, b) => b - a); // 从大到小
+    treeData.value = years.map(year => ({
+      key: `year_${year}`,
+      label: `${year}年`,
+      year: year,
+      children: REPORT_TYPES.map(t => ({
+        key: `year_${year}_${t.key}`,
+        label: t.label,
+        year: year,
+        typeKey: t.key,
+        typeLabel: t.label,
+      })),
+    }));
   } catch (error) {
     console.error(error);
   }
 };
-getDepartmentdata();
+onMounted(() => { loadTreeData(); });
   
   //点击左侧树形 获取右侧table列表
   const tableData = reactive([]);
@@ -210,43 +226,40 @@ getDepartmentdata();
     console.log(total.value );
   }
 // 点击树节点时的处理函数
-const handleNodeClick = async (data) => {
-  nodedata.value = data.label;
-  // 获取数据
-  const ProcessOutputRatedata = await ProcessOutputRate({ year: nodedata.value });
-  tableData.splice(0, tableData.length, ...ProcessOutputRatedata.data);
-  console.log(ProcessOutputRatedata);
-
-  getPoductData();
-  // 初始化柱状图
-  if (!mCharts && chart.value) {
-    mCharts = echarts.init(chart.value);
-    console.log('ECharts 实例初始化成功');
-  }
-
-  // 设置默认的柱状图配置
-  const defaultOption = {
-    xAxis: {
-      type: 'category',
-      data: [],
-    },
-    yAxis: {
-      type: 'value',
-    },
-    series: [
-      {
-        name: '合格率',
-        type: 'bar',
-        data: [], // 初始数据为空
-        barWidth: '40%',
-        barCategoryGap: '10%',
-      },
-    ],
-  };
+const currentYear = ref('');
+const currentTypeKey = ref('');
+const currentTypeLabel = ref('');
 
-  // 设置默认配置项
-  if (mCharts) {
-    mCharts.setOption(defaultOption);
+const handleNodeClick = async (node) => {
+  // 只有报表类型子节点才触发查询
+  if (node.typeKey) {
+    currentYear.value = node.year;
+    currentTypeKey.value = node.typeKey;
+    currentTypeLabel.value = node.typeLabel;
+    // 按报表类型路由到不同逻辑(目前只有 month_processrate 走旧接口,其余暂时空)
+    if (node.typeKey === 'month_processrate') {
+      nodedata.value = node.year;
+      const ProcessOutputRatedata = await ProcessOutputRate({ year: nodedata.value });
+      tableData.splice(0, tableData.length, ...ProcessOutputRatedata.data);
+      getPoductData();
+      // 初始化柱状图
+      if (!mCharts && chart.value) {
+        mCharts = echarts.init(chart.value);
+      }
+      if (mCharts) {
+        mCharts.setOption({
+          xAxis: { type: 'category', data: [] },
+          yAxis: { type: 'value' },
+          series: [{ name: '合格率', type: 'bar', data: [] }],
+        });
+      }
+    } else {
+      // 其他报表类型暂未实现,清空旧数据
+      tableData.splice(0, tableData.length);
+      gxtjData.splice(0, gxtjData.length);
+      if (mCharts) mCharts.clear();
+      ElMessage.info(`${node.typeLabel} 待实现`);
+    }
   }
 };
 
@@ -572,15 +585,25 @@ const ExportDetailsToExcel = async () => {
     display: flex;
   }
   .JKWTree-tree {
-    /*width: 300px;*/
     background-color: #fff;
     padding: 10px;
-    margin-right: 20px;
+    margin-right: 10px;
+    max-height: calc(100vh - 230px);
+    overflow-y: auto;
+    overflow-x: hidden;
   }
   .JKWTree-tree h3 {
-    font-size: 15px;
+    font-size: 14px;
     font-weight: 700;
-    margin: 10px 0;
+    margin: 4px 0 10px;
+  }
+  :deep(.el-tree-node__label) {
+    font-size: 13px;
+  }
+  /* 选中的树节点文字变红加粗 */
+  :deep(.el-tree-node.is-current > .el-tree-node__content .el-tree-node__label) {
+    color: red;
+    font-weight: bold;
   }
   .JKWTree-content {
     flex: 1;

+ 219 - 2
src/view/performance/12-orderAccounting/componets/xzgdtl.vue

@@ -29,9 +29,15 @@
       @click="oncreate"
     >保存</el-button>
 
+    <el-button
+      type="warning"
+      style="width: 130px; height: 40px;margin-bottom: 20px;margin-left: 20px;"
+      @click="openClaimDialog"
+    >索赔数量增加</el-button>
+
     <el-button
       type="primary"
-      style="width:80px; height: 40px;margin-bottom: 20px"
+      style="width:80px; height: 40px;margin-bottom: 20px;margin-left: 20px;"
       @click="emits('update:modelValue', false )"
     >退出</el-button>
 
@@ -45,7 +51,7 @@
       :cell-style="{ padding: '0px' }"
       :header-row-style="{ height: '20px' }"
       :header-cell-style="{ padding: '0px' }"
-      style="width: 100%;height: 75vh;"
+      style="width: 100%;height: 52vh;"
       @selection-change="handleSelectionChange"
     >
       <el-table-column
@@ -135,6 +141,73 @@
 
     </el-table>
 
+    <!-- 工单索赔记录(只读展示,修改请点上方「索赔数量增加」) -->
+    <div style="margin: 12px 0 6px; font-size: 14px; font-weight: 600; color: #303133;">
+      工单索赔记录
+      <span style="margin-left: 8px; font-size: 12px; font-weight: 400; color: #909399;">
+        只读,如需修改请点击上方「索赔数量增加」
+      </span>
+    </div>
+    <el-table
+      :data="claimViewRows"
+      border
+      style="width: 100%; height: 24vh;"
+      :row-style="{ height: '32px' }"
+      :cell-style="{ padding: '0px' }"
+      :header-row-style="{ height: '24px' }"
+      :header-cell-style="{ padding: '0px' }"
+      empty-text="暂无索赔记录"
+    >
+      <el-table-column label="工单号" prop="gdbh" width="120" />
+      <el-table-column label="索赔时间" prop="sys_rq" width="110" />
+      <el-table-column label="物料代号" prop="wlbh" width="180" />
+      <el-table-column label="物料名称" prop="物料名称" min-width="220" show-overflow-tooltip />
+      <el-table-column label="索赔数量(大张)" prop="num" width="160" />
+      <el-table-column label="索赔填补人" prop="sys_id" width="170" />
+    </el-table>
+
+  </el-dialog>
+
+  <!-- 索赔数量增加 弹窗:列表行 = 主表格(收发记录)1:1,填索赔大张后点「确认」才新增/修改索赔记录 -->
+  <el-dialog
+    v-model="claimDialogVisible"
+    title="工单索赔记录"
+    width="1150px"
+    append-to-body
+  >
+    <el-table
+      :data="claimRows"
+      border
+      style="width: 100%;"
+      :row-style="{ height: '32px' }"
+      :cell-style="{ padding: '0px' }"
+      :header-row-style="{ height: '24px' }"
+      :header-cell-style="{ padding: '0px' }"
+      empty-text="暂无数据"
+    >
+      <el-table-column label="工单号" prop="gdbh" width="120" />
+      <el-table-column label="索赔时间" prop="sys_rq" width="110" />
+      <el-table-column label="物料代号" prop="wlbh" width="180" />
+      <el-table-column label="物料名称" prop="物料名称" min-width="220" />
+      <el-table-column label="索赔数量(大张)" width="160">
+        <template #default="{ row }">
+          <el-input-number
+            v-model="row.num"
+            :min="0"
+            :step="1"
+            controls-position="right"
+            size="small"
+            style="width: 100%;"
+          />
+        </template>
+      </el-table-column>
+      <el-table-column label="索赔填补人" prop="sys_id" width="170" />
+    </el-table>
+
+    <template #footer>
+      <el-button @click="claimDialogVisible = false">关闭</el-button>
+      <el-button type="primary" :loading="claimSubmitting" @click="confirmClaims">确认</el-button>
+    </template>
   </el-dialog>
 
 </template>
@@ -180,6 +253,36 @@ const getFeedList = (params) => {
     params
   })
 }
+
+// ===== 工单索赔记录 =====
+const getClaimList = (params) => {
+  return service({
+    url: '/mes_server/order_super_loss/getClaimList',
+    method: 'get',
+    params
+  })
+}
+const addClaim = (data) => {
+  return service({
+    url: '/mes_server/order_super_loss/addClaim',
+    method: 'post',
+    data
+  })
+}
+const updateClaim = (data) => {
+  return service({
+    url: '/mes_server/order_super_loss/updateClaim',
+    method: 'post',
+    data
+  })
+}
+const deleteClaim = (data) => {
+  return service({
+    url: '/mes_server/order_super_loss/deleteClaim',
+    method: 'post',
+    data
+  })
+}
 </script>
 
 <script setup>
@@ -215,6 +318,120 @@ const getTable = async() => {
 }
 getTable()
 
+// ===== 工单索赔记录(弹窗内:列表行 = 主表格收发记录 1:1) =====
+const claimDialogVisible = ref(false)
+const claimSubmitting = ref(false)
+const claimRows = ref([])
+// 主弹窗下方只读展示的索赔记录
+const claimViewRows = ref([])
+const loadClaimView = async () => {
+  if (!props?.['gdbh']) {
+    claimViewRows.value = []
+    return
+  }
+  const res = await getClaimList({ gdbh: props.gdbh, yjno: props.yjno })
+  if (res.code === 0 && Array.isArray(res.data)) {
+    claimViewRows.value = res.data.map(c => ({
+      gdbh: c.gdbh,
+      sys_rq: c.sys_rq,
+      wlbh: (c.wlbh || '').trim(),
+      物料名称: c['物料名称'] || '',
+      num: Number(c.num) || 0,
+      sys_id: c.sys_id || '',
+    }))
+  } else {
+    claimViewRows.value = []
+  }
+}
+loadClaimView()
+// 主弹窗打开时刷新只读索赔记录
+watch(() => props.modelValue, (val) => {
+  if (val) loadClaimView()
+})
+
+// 打开弹窗:行 = 主表格(getOrderFeedList 返回的收发记录)1:1;已保存的索赔回填数量
+const openClaimDialog = async () => {
+  if (!props?.['gdbh']) {
+    ElMessage.warning('工单号不存在,无法索赔')
+    return
+  }
+  const today = new Date().toISOString().slice(0, 10)
+  claimRows.value = tableData.value.map(r => ({
+    gdbh: r.Gd_gdbh,
+    yjno: r.yj_Yjno,
+    wlbh: (r.yj_zzdh || '').trim(),
+    物料名称: (r.BOM_物料名称 || '').trim(),
+    num: 0,
+    Uniqid: null,
+    oldNum: 0,
+    sys_id: sys_id,
+    sys_rq: today,
+  }))
+  claimDialogVisible.value = true
+  // 回填已保存的索赔记录(按物料代号匹配到对应行)
+  const res = await getClaimList({ gdbh: props.gdbh, yjno: props.yjno })
+  if (res.code === 0 && Array.isArray(res.data)) {
+    res.data.forEach(c => {
+      const row = claimRows.value.find(r => !r.Uniqid && r.wlbh === (c.wlbh || '').trim())
+      if (row) {
+        row.Uniqid = c.Uniqid
+        row.num = Number(c.num) || 0
+        row.oldNum = row.num
+        row.sys_rq = c.sys_rq || today
+        row.sys_id = c.sys_id || sys_id
+      }
+    })
+  }
+}
+
+// 点「确认」→ 批量保存:新填数量>0 新增;已保存的数量变了 修改;已保存的数量清 0 删除
+const confirmClaims = async () => {
+  const toAdd = claimRows.value.filter(r => !r.Uniqid && r.num > 0)
+  const toUpdate = claimRows.value.filter(r => r.Uniqid && r.num > 0 && r.num !== r.oldNum)
+  const toDelete = claimRows.value.filter(r => r.Uniqid && (!r.num || r.num <= 0))
+  if (toAdd.length + toUpdate.length + toDelete.length === 0) {
+    ElMessage.info('没有需要保存的索赔数量')
+    return
+  }
+  claimSubmitting.value = true
+  try {
+    for (const r of toAdd) {
+      const res = await addClaim({
+        gdbh: r.gdbh,
+        yjno: r.yjno,
+        wlbh: r.wlbh,
+        wl_name: r['物料名称'],
+        num: r.num,
+        sys_id: r.sys_id,
+      })
+      if (res.code !== 0) {
+        ElMessage.error(res.msg || '新增失败')
+        return
+      }
+    }
+    for (const r of toUpdate) {
+      const res = await updateClaim({ Uniqid: r.Uniqid, num: r.num })
+      if (res.code !== 0) {
+        ElMessage.error(res.msg || '修改失败')
+        return
+      }
+    }
+    for (const r of toDelete) {
+      const res = await deleteClaim({ Uniqid: r.Uniqid })
+      if (res.code !== 0) {
+        ElMessage.error(res.msg || '删除失败')
+        return
+      }
+    }
+    ElMessage.success('索赔记录保存成功')
+    claimDialogVisible.value = false
+    await loadClaimView()
+    emits('update-data', false)
+  } finally {
+    claimSubmitting.value = false
+  }
+}
+
 const handleSelectionChange = (val) => {
   multipleSelection.value = val
   console.log(multipleSelection.value)

+ 1 - 1
src/view/performance/12-orderAccounting/index.vue

@@ -519,7 +519,7 @@ const tableCols1 = [
   // { label: '超损工单', prop: 'csgd', width: '110' ,sortable:'sortable'},
   { label: '工单编号', prop: 'Gd_gdbh', width: '110',sortable:'sortable',fixed:'fixed',align:'left'},
   { label: '参与考核', prop: '考核', width: '110' ,sortable:'sortable'},
-  { label: '工单类型', prop: '工单类型', width: '70'},
+  { label: '材料索赔', prop: '材料索赔', width: '90'},
   { label: '印件号', prop: 'jjcp_yjno', width: '70'},
   { label: '联数', prop: 'yj_ls', width: '70'},
   { label: '产品代号', prop: '成品编码', width: '110' ,sortable:'sortable'},

+ 83 - 17
src/view/performance/chejianbaogong.vue

@@ -742,15 +742,17 @@
 						  <el-descriptions :column="9" border>
 							<el-descriptions-item :span="9">
 								<el-row :gutter="24" style="margin-bottom: 0px;margin-top: 0px;">
-								  <el-col :span="6" style="margin-bottom: 0px;margin-top: 0px;">
+								  <el-col :span="8" style="margin-bottom: 0px;margin-top: 0px;">
 									<el-form-item label="日期:" prop="id" style="margin-top:0px; margin-bottom: 0px;">
-									  <el-input v-model="huanxingData.日期"  placeholder="" style="margin-top:0px; margin-bottom: 0px;"/>
+									  <el-date-picker v-model="huanxingData.日期" type="date" placeholder="请选择日期"
+										format="YYYY-MM-DD" value-format="YYYY-MM-DD" :clearable="false"
+										style="width:100%; margin-top:0px; margin-bottom: 0px;"/>
 									</el-form-item>
 								  </el-col>
-								  <el-col :span="2" style="margin-bottom: 0px;margin-top: 0px;">
+								  <el-col :span="1" style="margin-bottom: 0px;margin-top: 0px;">
   
 								  </el-col>
-								  <el-col :span="6" style="margin-bottom: 0px;margin-top: 0px;">
+								  <el-col :span="7" style="margin-bottom: 0px;margin-top: 0px;">
 									  <el-form-item label="机台编号:" prop="id" style="margin-top:0px; margin-bottom: 0px;">
 									   <el-input v-model="huanxingData.机台编号"  placeholder="" style="margin-top:0px; margin-bottom: 0px;"/>
 									  </el-form-item>
@@ -864,19 +866,19 @@
 								<el-row :gutter="24" style="margin-bottom: 0px;margin-top: 0px;">
 								  <el-col :span="12" style="margin-bottom: 0px;margin-top: 0px;">
 									<el-form-item label="机长签字" prop="id" style="margin-bottom: 0px;margin-top: 0px;">
-									  <el-input v-model="huanxingData.机长"  placeholder="" style="margin-bottom: 0px;margin-top: 0px;"/>
+									  <el-input v-model="huanxingData.机长" placeholder="输入员工编号回车" @keyup.enter="onHxNameLookup('机长')" style="margin-bottom: 0px;margin-top: 0px;"/>
 									</el-form-item>
 								  </el-col>
 								</el-row>
 								<el-row :gutter="24" style="margin-bottom: 0px;margin-top: 0px;">
 								  <el-col :span="12" style="margin-bottom: 0px;margin-top: 0px;">
 									<el-form-item label="带班主管签字" prop="id" style="margin-bottom: 0px;margin-top: 0px;">
-									  <el-input v-model="huanxingData.班长"  placeholder="" style="margin-bottom: 0px;margin-top: 0px;"/>
+									  <el-input v-model="huanxingData.班长" placeholder="输入员工编号回车" @keyup.enter="onHxNameLookup('班长')" style="margin-bottom: 0px;margin-top: 0px;"/>
 									</el-form-item>
 								  </el-col>
 								  <el-col :span="12" style="margin-bottom: 0px;margin-top: 0px;">
 									<el-form-item label="质量巡查员签字" prop="id" style="margin-bottom: 0px;margin-top: 0px;">
-									  <el-input v-model="huanxingData.质量巡查员"  placeholder="" style="margin-bottom: 0px;margin-top: 0px;"/>
+									  <el-input v-model="huanxingData.质量巡查员" placeholder="输入员工编号回车" @keyup.enter="onHxNameLookup('质量巡查员')" style="margin-bottom: 0px;margin-top: 0px;"/>
 									</el-form-item>
 								  </el-col>
 								</el-row>
@@ -1840,6 +1842,14 @@
 				  </div>
 				</el-form>
 			  </el-dialog>
+
+			  <!--换型清场 清场确认人 员工选择-->
+			  <el-dialog v-model="hxNameVisible" :title="'选择' + hxNameField" style="width: 20%">
+				<el-table :data="hxNameList" border :show-overflow-tooltip="true" @row-click="onHxNamePick">
+				  <el-table-column prop="员工编号" label="员工编号"></el-table-column>
+				  <el-table-column prop="ygxm" label="员工姓名"></el-table-column>
+				</el-table>
+			  </el-dialog>
 			  
 			  <!-- 日产量上报拉料 -->
 			  <el-dialog v-model="llblModellist" :before-close="() => llblModellist = false" style="width: 20%">
@@ -2358,6 +2368,7 @@
 	ModelChangeRecord,
 	ComplaintRecord,
 	RemodelDetail,
+	RemodelLastOrders,
 	MachineTeamAdd,
 	remodelDataAdd,
 	remodelDataEdit,
@@ -2496,6 +2507,10 @@ const warningres = (arr) => {
   const huanxingtreeData=ref([])
   const huanxingselectData = ref([])
   const huanxingData = ref({})
+  // 换型清场-清场确认人 员工编号查姓名
+  const hxNameVisible = ref(false)
+  const hxNameList = ref([])
+  const hxNameField = ref('')
   const dbformData=ref({})
   const huanxingstatus=ref(false)
   // 定义树的数据
@@ -3290,27 +3305,78 @@ const warningres = (arr) => {
   const fujiaselectData=ref([])
   const inspectionRecordsData=ref([])
   const searchInfo = ref({})
-  const onHxadd = () => {
+  const onHxadd = async () => {
 	huanxingstatus.value=true
 	huanxingType.value=true
 	huanxingStatus.value=1
-	huanxingData.value.班组=''
-	huanxingData.value.码包B=''
-	huanxingData.value.工单编号A=''
-	huanxingData.value.印件工序A=''
-	huanxingData.value.码包号A=''
-	huanxingData.value.工单编号B=''
-	huanxingData.value.印件工序B=''
+	// 日期默认当天
+	const now = new Date()
+	const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
+	huanxingData.value.日期 = today
+	huanxingData.value.班组 = BZMC.value ?? ''
+	huanxingData.value.机台编号 = formData.value?.机台号 ?? ''
+	// 清空历史值
+	huanxingData.value.工单编号A = ''
+	huanxingData.value.印件名称A = ''
+	huanxingData.value.印件工序A = ''
+	huanxingData.value.码包号A = ''
+	huanxingData.value.工单编号B = ''
+	huanxingData.value.印件名称B = ''
+	huanxingData.value.印件工序B = ''
+	huanxingData.value.码包B = ''
 	huanxingData.value.机长=''
 	huanxingData.value.班长=''
 	huanxingData.value.质量巡查员=''
-	huanxingData.value.印件名称A=''
-	huanxingData.value.印件名称B=''
 	huanxingData.value.项目1=false
 	huanxingData.value.项目2=false
 	huanxingData.value.项目3=false
 	huanxingData.value.项目4=false
 	huanxingData.value.项目5=false
+
+	// 从设备_产量采集按机台取最新两个工单(工序名称 + 印件名称)
+	// 最新的一条 = 换到了新工单,放"到(B)"侧;次新的一条 = 换型前的工单,放"从(A)"侧
+	const machine = huanxingData.value.机台编号
+	if (machine) {
+	  const res = await RemodelLastOrders({ machine })
+	  if (res.code === 0 && Array.isArray(res.data) && res.data.length) {
+		const first = res.data[0]
+		huanxingData.value.工单编号B = first['工单编号'] || ''
+		huanxingData.value.印件工序B = first['工序名称'] || ''
+		huanxingData.value.印件名称B = first['印件名称'] || ''
+		const second = res.data[1]
+		if (second) {
+		  huanxingData.value.工单编号A = second['工单编号'] || ''
+		  huanxingData.value.印件工序A = second['工序名称'] || ''
+		  huanxingData.value.印件名称A = second['印件名称'] || ''
+		}
+	  }
+	}
+  }
+
+  // 清场确认人:输入员工编号回车 → 查询姓名(只取姓名,不保留编号)
+  const onHxNameLookup = async (field) => {
+	const code = (huanxingData.value[field] || '').trim()
+	if (!code) return
+	const res = await getYg({ sczl_bh: code })
+	if (res.code === 0 && Array.isArray(res.data) && res.data.length) {
+	  if (res.data.length === 1) {
+		huanxingData.value[field] = res.data[0].ygxm
+	  } else {
+		hxNameField.value = field
+		hxNameList.value = res.data
+		hxNameVisible.value = true
+	  }
+	} else {
+	  ElMessage.warning('未找到该员工编号')
+	}
+  }
+
+  // 员工列表点击 → 回填姓名
+  const onHxNamePick = (row) => {
+	if (row && row.ygxm) {
+	  huanxingData.value[hxNameField.value] = row.ygxm
+	}
+	hxNameVisible.value = false
   }
   const onHxedit = () => {
 	huanxingType.value=true

+ 133 - 23
src/view/quality/Customerfeedback.vue

@@ -146,11 +146,15 @@
           </el-col>
           <el-col :span="10">
             <el-form-item label="客诉日期">
-              <el-input
+              <el-date-picker
                 id="f_客诉日期"
                 v-model="formData.客诉日期"
-                placeholder="回车为当天"
-                readonly
+                type="date"
+                placeholder="请选择日期"
+                format="YYYY.MM.DD"
+                value-format="YYYY.MM.DD"
+                :clearable="false"
+                style="width: 100%;"
                 @keydown="(e) => handleFieldKeydown(e, 'f_客诉日期')"
               />
             </el-form-item>
@@ -170,7 +174,7 @@
 
         <!-- 第二行 -->
         <el-row :gutter="15">
-          <el-col :span="8">
+          <el-col :span="7">
             <el-form-item label="订单编号">
               <el-input
                 id="f_订单编号"
@@ -179,7 +183,7 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="5">
+          <el-col :span="6">
             <el-form-item label="产品编号">
               <el-input
                 id="f_产品编号"
@@ -297,12 +301,13 @@
 
       <template #footer>
         <el-button @click="formVisible = false">取消</el-button>
-        <el-button type="primary" @click="onSubmit">确定</el-button>
+        <el-button id="btn_submit" type="primary" @click="onSubmit">确定</el-button>
       </template>
     </el-dialog>
 
     <!-- ============ 方式 选择小弹窗 ============ -->
-    <el-dialog v-model="wayVisible" title="选择方式" width="300px" @opened="onWayOpened">
+    <el-dialog v-model="wayVisible" title="选择方式" width="300px"
+      @opened="onWayOpened" @keydown="handleWayKeydown">
       <div style="display: flex; justify-content: space-around; padding: 20px 0;">
         <el-button id="way_书面" @click="selectWay('书面')">书面</el-button>
         <el-button id="way_口头" @click="selectWay('口头')">口头</el-button>
@@ -310,12 +315,13 @@
     </el-dialog>
 
     <!-- ============ 性质 选择小弹窗 ============ -->
-    <el-dialog v-model="natureVisible" title="选择性质" width="300px" @opened="onNatureOpened">
+    <el-dialog v-model="natureVisible" title="选择性质" width="300px"
+      @opened="onNatureOpened" @keydown="handleNatureKeydown">
       <div style="display: flex; justify-content: space-around; padding: 20px 0;">
-        <el-button @click="selectNature('A类')">A类</el-button>
-        <el-button @click="selectNature('B类')">B类</el-button>
-        <el-button @click="selectNature('C类')">C类</el-button>
-        <el-button @click="selectNature('D类')">D类</el-button>
+        <el-button id="nature_A" @click="selectNature('A类')">A类</el-button>
+        <el-button id="nature_B" @click="selectNature('B类')">B类</el-button>
+        <el-button id="nature_C" @click="selectNature('C类')">C类</el-button>
+        <el-button id="nature_D" @click="selectNature('D类')">D类</el-button>
       </div>
     </el-dialog>
 
@@ -344,7 +350,7 @@
         @row-dblclick="pickProduct"
         row-key="产品编号"
       >
-        <el-table-column prop="产品编号" label="产品编号" width="160" />
+        <el-table-column prop="产品编号" label="产品编号" width="220" show-overflow-tooltip />
         <el-table-column prop="产品名称" label="产品名称" />
       </el-table>
       <template #footer>
@@ -483,7 +489,13 @@ const loadList = async (params = {}) => {
 
 const handleNodeClick = async (node) => {
   if (!node.type) return
-  await loadList({ type: node.type, code: node.code || '', name: node.name || '' })
+  await loadList({
+    type: node.type,
+    code: node.code || '',
+    name: node.name || '',
+    year: node.year || '',
+    month: node.month || ''
+  })
 }
 
 // =========== 当前选中的主表行 ===========
@@ -658,6 +670,15 @@ const focusField = async (id) => {
     try { el.select() } catch (_) {}
   }
 }
+// 聚焦指定 id 的按钮(element-plus 的 el-button 真实 focus 点是内部的 button)
+const focusById = (id) => {
+  nextTick(() => {
+    const el = document.getElementById(id)
+    if (!el) return
+    const btn = el.querySelector('button') || el
+    try { btn.focus() } catch (_) {}
+  })
+}
 
 /**
  * 表单字段键盘处理
@@ -673,7 +694,8 @@ const handleFieldKeydown = (e, currentId) => {
     e.preventDefault()
     // 特殊字段:弹选择弹窗
     if (currentId === 'f_客诉日期') {
-      formData.客诉日期 = dayjs().format('YYYY.MM.DD')
+      // 已有选择则保留,空值才补当天,然后跳到下一字段
+      if (!formData.客诉日期) formData.客诉日期 = dayjs().format('YYYY.MM.DD')
       nextField(currentId)
       return
     }
@@ -694,13 +716,16 @@ const handleFieldKeydown = (e, currentId) => {
       return
     }
     if (currentId === 'f_客诉描述' && e.shiftKey) return // Shift+Enter 在 textarea 里换行
-    if (currentId === 'f_客诉描述') return // 普通 Enter 在 textarea 里换行
+    if (currentId === 'f_客诉描述') {
+      // 普通 Enter 跳到下一个字段(缺陷关键字),车间键盘操作为主
+      e.preventDefault()
+      nextField(currentId)
+      return
+    }
     nextField(currentId)
     return
   }
 
-  if (isTextarea) return
-
   if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
     e.preventDefault()
     nextField(currentId)
@@ -716,12 +741,17 @@ const nextField = (currentId) => {
   const idx = fieldOrder.indexOf(currentId)
   if (idx >= 0 && idx < fieldOrder.length - 1) {
     focusField(fieldOrder[idx + 1])
+  } else if (idx === fieldOrder.length - 1) {
+    // 最后一个字段:跳到确定按钮
+    focusById('btn_submit')
   }
 }
 const prevField = (currentId) => {
   const idx = fieldOrder.indexOf(currentId)
   if (idx > 0) {
     focusField(fieldOrder[idx - 1])
+  } else if (idx === 0) {
+    // 第一个字段按 ↑:跳到取消按钮(可选,保持循环)
   }
 }
 
@@ -796,6 +826,17 @@ const onSubmit = async () => {
   if (!formData.客诉日期) {
     formData.客诉日期 = dayjs().format('YYYY.MM.DD')
   }
+  try {
+    await ElMessageBox.confirm(`确定存储数据吗?`, '提示', {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'info',
+      closeOnClickModal: false,
+    })
+  } catch (_) {
+    // 用户点取消 / Esc
+    return
+  }
   try {
     const res = isEdit.value
       ? await editCustomerFeedback(formData)
@@ -815,6 +856,9 @@ const onSubmit = async () => {
 
 // =========== 方式 选择 ===========
 const wayVisible = ref(false)
+const wayBtnIds = ['way_书面', 'way_口头']
+const wayBtnValues = ['书面', '口头']
+const wayHighlightIndex = ref(0)
 const selectWay = (val) => {
   formData.客诉方式 = val
   wayVisible.value = false
@@ -822,14 +866,34 @@ const selectWay = (val) => {
 }
 const onWayOpened = async () => {
   await nextTick()
-  // 默认聚焦当前值,否则聚焦第一个
   const cur = formData.客诉方式
-  const target = cur === '口头' ? document.getElementById('way_口头') : document.getElementById('way_书面')
-  if (target) target.focus()
+  wayHighlightIndex.value = cur === '口头' ? 1 : 0
+  focusById(wayBtnIds[wayHighlightIndex.value])
+}
+const handleWayKeydown = (e) => {
+  if (e.key === 'Escape') { wayVisible.value = false; return }
+  if (e.key === 'Enter') {
+    e.preventDefault()
+    selectWay(wayBtnValues[wayHighlightIndex.value])
+    return
+  }
+  const total = wayBtnIds.length
+  if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
+    e.preventDefault()
+    wayHighlightIndex.value = (wayHighlightIndex.value - 1 + total) % total
+    focusById(wayBtnIds[wayHighlightIndex.value])
+  } else if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
+    e.preventDefault()
+    wayHighlightIndex.value = (wayHighlightIndex.value + 1) % total
+    focusById(wayBtnIds[wayHighlightIndex.value])
+  }
 }
 
 // =========== 性质 选择 ===========
 const natureVisible = ref(false)
+const natureBtnIds = ['nature_A', 'nature_B', 'nature_C', 'nature_D']
+const natureBtnValues = ['A类', 'B类', 'C类', 'D类']
+const natureHighlightIndex = ref(0)
 const selectNature = (val) => {
   formData.客诉性质 = val
   natureVisible.value = false
@@ -837,9 +901,29 @@ const selectNature = (val) => {
 }
 const onNatureOpened = async () => {
   await nextTick()
-  // 让弹窗能接受键盘
+  const cur = formData.客诉性质
+  const idx = natureBtnValues.indexOf(cur)
+  natureHighlightIndex.value = idx >= 0 ? idx : 0
+  focusById(natureBtnIds[natureHighlightIndex.value])
+}
+const handleNatureKeydown = (e) => {
+  if (e.key === 'Escape') { natureVisible.value = false; return }
+  if (e.key === 'Enter') {
+    e.preventDefault()
+    selectNature(natureBtnValues[natureHighlightIndex.value])
+    return
+  }
+  const total = natureBtnIds.length
+  if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
+    e.preventDefault()
+    natureHighlightIndex.value = (natureHighlightIndex.value - 1 + total) % total
+    focusById(natureBtnIds[natureHighlightIndex.value])
+  } else if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
+    e.preventDefault()
+    natureHighlightIndex.value = (natureHighlightIndex.value + 1) % total
+    focusById(natureBtnIds[natureHighlightIndex.value])
+  }
 }
-
 // =========== 产品编号 弹窗 ===========
 const productModal = ref(false)
 const productKeyword = ref('')
@@ -881,6 +965,28 @@ const pickProduct = (row) => {
   productModal.value = false
   nextTick(() => focusField('f_客户编号'))
 }
+// 让高亮行滚动到可视区域(解决 "按下键选中到后面了但滚动条没动")
+const scrollHighlightedRow = (tableRef, list, index) => {
+  nextTick(() => {
+    try {
+      const table = tableRef?.value
+      if (!table || index < 0 || index >= list.length) return
+      // Element Plus / Element UI 都有 setCurrentRow,且 bodyWrapper 可滚动
+      const body = table.$el?.querySelector('.el-scrollbar__wrap') || table.$el?.querySelector('.el-table__body-wrapper')
+      if (!body) return
+      const rowEl = table.$el?.querySelector(`.el-table__body-wrapper tbody tr:nth-child(${index + 1})`)
+      if (rowEl) {
+        const bodyRect = body.getBoundingClientRect()
+        const rowRect = rowEl.getBoundingClientRect()
+        if (rowRect.bottom > bodyRect.bottom) {
+          body.scrollTop += (rowRect.bottom - bodyRect.bottom) + 28
+        } else if (rowRect.top < bodyRect.top) {
+          body.scrollTop -= (bodyRect.top - rowRect.top) + 28
+        }
+      }
+    } catch (_) {}
+  })
+}
 const handleProductModalKeydown = (e) => {
   // 拦截弹窗内部的 方向键 / 回车 / Esc
   if (e.key === 'Escape') {
@@ -893,12 +999,14 @@ const handleProductModalKeydown = (e) => {
     e.preventDefault()
     productHighlightIndex.value = Math.min(productHighlightIndex.value + 1, productList.value.length - 1)
     productTableRef.value?.setCurrentRow(productList.value[productHighlightIndex.value])
+    scrollHighlightedRow(productTableRef, productList.value, productHighlightIndex.value)
     return
   }
   if (e.key === 'ArrowUp') {
     e.preventDefault()
     productHighlightIndex.value = Math.max(productHighlightIndex.value - 1, 0)
     productTableRef.value?.setCurrentRow(productList.value[productHighlightIndex.value])
+    scrollHighlightedRow(productTableRef, productList.value, productHighlightIndex.value)
     return
   }
   if (e.key === 'Enter') {
@@ -962,12 +1070,14 @@ const handleClientModalKeydown = (e) => {
     e.preventDefault()
     clientHighlightIndex.value = Math.min(clientHighlightIndex.value + 1, clientList.value.length - 1)
     clientTableRef.value?.setCurrentRow(clientList.value[clientHighlightIndex.value])
+    scrollHighlightedRow(clientTableRef, clientList.value, clientHighlightIndex.value)
     return
   }
   if (e.key === 'ArrowUp') {
     e.preventDefault()
     clientHighlightIndex.value = Math.max(clientHighlightIndex.value - 1, 0)
     clientTableRef.value?.setCurrentRow(clientList.value[clientHighlightIndex.value])
+    scrollHighlightedRow(clientTableRef, clientList.value, clientHighlightIndex.value)
     return
   }
   if (e.key === 'Enter') {

+ 250 - 53
src/view/quality/ManagementQuality.vue

@@ -1,69 +1,266 @@
 <template>
   <div>
-    <el-container>
-      <el-aside width="200px">
-        <div class="JKWTree-tree">
-          <h3>产品质量改善措施管理</h3>
-          <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
-        </div>
-      </el-aside>
-      <el-container>
-		  
-        <el-main>
+    <Layout>
+      <LayoutHeader>
+        <el-form inline>
+          <el-form-item>
+            <el-button type="primary" icon="Download" @click="exportDetail" style="margin: 5px;float: right;">导出到Excel(明细)</el-button>
+            <el-button type="primary" icon="Download" @click="exportSummary" style="margin: 5px;float: right;">导出到Excel(汇总)</el-button>
+          </el-form-item>
+        </el-form>
+      </LayoutHeader>
 
-        </el-main>
-      </el-container>
-    </el-container>
+      <Layout>
+        <LayoutSider :width="260" style="background:#fff;border-right:1px solid #e5e6eb;overflow:auto;">
+          <div style="padding:12px 14px;font-size:14px;font-weight:600;color:#1d2129;border-bottom:1px solid #f0f0f0;">
+            工程序点质量分析记录
+          </div>
+          <el-tree
+            :data="treeData"
+            highlight-current
+            node-key="key"
+            :expand-on-click-node="false"
+            :props="{ label: 'label', children: 'children' }"
+            @node-click="handleNodeClick"
+          />
+        </LayoutSider>
+
+        <LayoutContent style="padding:12px;overflow:auto;background:#f5f6f7;">
+          <!-- 上方:工单列表 -->
+          <div style="background:#fff;border:1px solid #e5e6eb;border-radius:4px;margin-bottom:10px;">
+            <div style="padding:8px 14px;font-size:14px;font-weight:600;color:#1d2129;border-bottom:1px solid #f0f0f0;">
+              工单列表
+              <span style="margin-left:10px;font-size:12px;color:#909399;font-weight:400;">
+                {{ currentNodeLabel || '(请在左侧选择日期/客户)' }}
+              </span>
+            </div>
+            <el-table
+              :data="tableData1"
+              row-key="ID"
+              highlight-current-row
+              border
+              style="width:100%;height:34vh;"
+              :row-style="{ height:'20px' }"
+              :cell-style="{ padding:'0px' }"
+              :header-row-style="{ height:'22px' }"
+              :header-cell-style="{ padding:'4px 0' }"
+              show-overflow-tooltip="true"
+              @row-click="onRowClickTop"
+            >
+              <el-table-column v-for="col in tableCols1" :key="col.prop"
+                :prop="col.prop" :label="col.label" :width="col.width"
+                :fixed="col.fixed" :sortable="col.sortable" align="center"
+              />
+            </el-table>
+          </div>
+
+          <!-- 下方:工序质量缺陷明细 -->
+          <div style="background:#fff;border:1px solid #e5e6eb;border-radius:4px;">
+            <div style="padding:8px 14px;font-size:14px;font-weight:600;color:#1d2129;border-bottom:1px solid #f0f0f0;">
+              工序质量缺陷明细
+              <span style="margin-left:10px;font-size:12px;color:#909399;font-weight:400;">
+                {{ currentRow?.['Gd_gdbh'] ? '工单 ' + currentRow['Gd_gdbh'] + ' · 印件号 ' + currentRow['jjcp_yjno'] : '(请先在上方选择一行工单)' }}
+              </span>
+            </div>
+            <el-table
+              :data="tableData2"
+              border
+              style="width:100%;height:42vh;"
+              :row-style="{ height:'24px' }"
+              :cell-style="{ padding:'0px' }"
+              :header-row-style="{ height:'24px' }"
+              :header-cell-style="{ padding:'4px 0' }"
+              show-overflow-tooltip="true"
+              empty-text="暂无工序质量缺陷数据"
+            >
+              <el-table-column
+                v-for="col in tableCols2" :key="col.prop"
+                :prop="col.prop" :label="col.label" :width="col.width"
+                :min-width="col.minWidth" align="center"
+              />
+            </el-table>
+          </div>
+        </LayoutContent>
+      </Layout>
+    </Layout>
   </div>
 </template>
+
 <script setup>
-import {
-  getDepartment,
-  getMachineInfo
-} from '@/api/mes/job'
-import {
-  createCompany,
-  deleteCompany,
-  deleteCompanyByIds,
-  updateCompany,
-  findCompany,
-  getCompanyList
-} from '@/api/company'
-// 全量引入格式化工具 请按需保留
-import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
-import { ElMessage, ElMessageBox } from 'element-plus'
-import { ref, reactive } from 'vue'
-import { useUserStore } from '@/pinia/modules/user'
-const userStore = useUserStore()
-const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
-defineOptions({
-    name: 'Company'
-})
+import { ElMessage } from 'element-plus'
+import { Download } from '@element-plus/icons-vue'
+import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue'
+import { ref, watch, onMounted } from 'vue'
+import * as XLSX from 'xlsx'
+import { getSide, getTable, getOrderQuality } from '@/api/mes_api_gty/orderAccounting'
 
-</script>
+defineOptions({ name: 'ManagementQuality' })
 
-<style>
-.JKWTree-container {
-  display: flex;
+// ========== 左侧树 ==========
+// 接口返回 data 为对象:{ "202511-54": [{客户名称, 客户编号, total}, ...], ... }
+const treeData = ref([])
+const loadTree = async () => {
+  const res = await getSide()
+  if (res.code !== 0 || !res.data) return
+  const data = res.data
+  const list = []
+  if (Array.isArray(data)) {
+    // 兼容数组形式
+    data.forEach((node, i) => {
+      list.push({
+        key: 'date-' + i,
+        label: node.label || node.dateLabel || node.date,
+        date: node.date,
+        code: '',
+        children: (node.children || []).map((c, j) => ({
+          key: `c-${i}-${j}`,
+          label: `${c['客户编号']}【${c['客户名称']}】(工单数:${c.total ?? ''})`,
+          date: node.date,
+          code: c['客户编号'] || '',
+        }))
+      })
+    })
+  } else {
+    // 对象形式(当前接口实际返回)
+    Object.entries(data).forEach(([key, value], i) => {
+      const [date, total] = String(key).split('-')
+      list.push({
+        key: 'date-' + i,
+        label: `${date}(工单数:${total ?? ''})`,
+        date: date,
+        code: '',
+        children: (Array.isArray(value) ? value : []).map((c, j) => ({
+          key: `c-${i}-${j}`,
+          label: `${c['客户编号']}【${c['客户名称']}】(工单数:${c.total ?? ''})`,
+          date: date,
+          code: c['客户编号'] || '',
+        }))
+      })
+    })
+  }
+  treeData.value = list
 }
-/* 选中某行时的背景色*/
-.el-table__body tr.current-row>td {
-  background: #ff80ff !important;
+loadTree()
+
+// ========== 上方主表(与 index.vue 完全一致的列) ==========
+const tableCols1 = [
+  { label: '工单编号', prop: 'Gd_gdbh', width: '110', fixed: 'left', sortable: 'sortable' },
+  { label: '印件号', prop: 'jjcp_yjno', width: '70' },
+  { label: '联数', prop: 'yj_ls', width: '60' },
+  { label: '产品代号', prop: '成品编码', width: '110', sortable: 'sortable' },
+  { label: '印件代号', prop: 'yjdh', width: '110', sortable: 'sortable' },
+  { label: '产品名称', prop: '成品名称', width: '240', sortable: 'sortable' },
+  { label: '实际投料', prop: '实际投料', width: '85' },
+  { label: '计量单位', prop: '计量单位', width: '90' },
+  { label: '入仓日期', prop: 'warehousing_date', width: '110', sortable: 'sortable' },
+  { label: '入仓数量', prop: 'warehousing_num', width: '85' },
+  { label: '目标合格率', prop: 'target_rate', width: '120', sortable: 'sortable' },
+  { label: '实际合格率', prop: 'real_rate', width: '120', sortable: 'sortable' },
+  { label: '奖惩系数', prop: 'reward_rate', width: '110', sortable: 'sortable' },
+  { label: '奖罚金额合计', prop: 'reward_money', width: '135', sortable: 'sortable' },
+  { label: '废品合计', prop: '废品合计', width: '110', sortable: 'sortable' },
+  { label: '工单无形损', prop: '工单无形损', width: '120', sortable: 'sortable' },
+  { label: '材料废', prop: '材料废', width: '70' },
+  { label: '零头处理', prop: '零头处理', width: '90' },
+  { label: '外发废', prop: '外发废', width: '70' },
+  { label: '分摊废', prop: '分摊废', width: '70' },
+  { label: '工单计划损耗', prop: '工单计划损耗', width: '110' },
+  { label: '工单制程废', prop: 'zcfp', width: '110' },
+  { label: '工单检验废', prop: '工单质检废', width: '110' },
+]
+
+const tableData1 = ref([])
+const currentRow = ref(null)
+const handleNodeClick = async (node) => {
+  const params = {
+    date: node.date,
+    code: node.code || '',
+    limit: 9999,
+    page: 1
+  }
+  const res = await getTable(params)
+  if (res.code === 0) {
+    tableData1.value = res.data.map((item) => ({
+      ...item,
+      date: node.date,
+      考核: String(item['考核']) === '是' ? '参与' : '否'
+    }))
+  }
 }
-.JKWTree-tree {
-  width: 300px;
-  background-color: #fff;
-  padding: 10px;
-  margin-right: 20px;
+
+// 点击上方表格行 → 记录当前行并加载下方工序质量缺陷明细
+const onRowClickTop = async (row) => {
+  currentRow.value = row
+  if (!row?.['Gd_gdbh'] || !row?.['jjcp_yjno']) {
+    tableData2.value = []
+    return
+  }
+  const wasteRef = Number(row['工单质检废']) || 0
+  const res = await getOrderQuality({
+    order: row['Gd_gdbh'],
+    yjno: row['jjcp_yjno'],
+    waste_ref: wasteRef
+  })
+  if (res.code === 0) {
+    tableData2.value = res.data || []
+  } else {
+    tableData2.value = []
+    ElMessage.warning(res.msg || '查询工序质量缺陷失败')
+  }
 }
 
-.JKWTree-tree h3 {
-  font-size: 15px;
-  font-weight: 700;
-  margin: 10px 0;
+// 通用:列配置 + 数据 → Excel
+const exportColsToXlsx = (cols, data, filename, sheetName = 'Sheet1') => {
+  if (!data || data.length === 0) {
+    ElMessage.warning('当前没有可导出的数据')
+    return
+  }
+  const headerMap = {}
+  const fields = []
+  cols.forEach(c => {
+    if (!c.prop) return
+    headerMap[c.prop] = c.label
+    fields.push(c.prop)
+  })
+  const rows = data.map(r => {
+    const out = {}
+    fields.forEach(f => { out[headerMap[f]] = r[f] })
+    return out
+  })
+  const ws = XLSX.utils.json_to_sheet(rows)
+  ws['!cols'] = fields.map(f => ({ wch: Math.max(8, String(headerMap[f]).length * 1.5) }))
+  const wb = XLSX.utils.book_new()
+  XLSX.utils.book_append_sheet(wb, ws, sheetName)
+  XLSX.writeFile(wb, filename)
 }
 
-.JKWTree-content {
-  flex: 1;
+// 导出汇总(上方工单列表)
+const exportSummary = () => {
+  exportColsToXlsx(tableCols1, tableData1.value, `工单列表_${currentNodeLabel.value || '全部'}.xlsx`, '工单列表')
 }
+
+// 导出明细(下方工序质量缺陷)
+const exportDetail = () => {
+  exportColsToXlsx(tableCols2, tableData2.value, `工序质量缺陷明细_${currentRow.value?.['Gd_gdbh'] || '全部'}.xlsx`, '工序质量缺陷明细')
+}
+
+// ========== 下方工序质量缺陷明细 ==========
+const tableCols2 = [
+  { label: '工序质量缺陷', prop: '工序质量缺陷', width: '160' },
+  { label: '废品合计', prop: '废品合计', width: '110' },
+  { label: '占比', prop: '占比', width: '100' },
+  { label: '品质记录及预防措施', prop: '品质记录及预防措施', width: '160' },
+  { label: '印件号', prop: '印件号', width: '100' },
+  { label: '印件名称', prop: '印件名称', minWidth: '260' },
+]
+const tableData2 = ref([])
+
+// 避免下方表残留上一个工单数据
+watch(currentRow, (row) => {
+  if (!row) tableData2.value = []
+})
+</script>
+
+<style>
+body .arco-layout-sider { background:#fff !important; }
 </style>

+ 253 - 46
src/view/quality/Productquality.vue

@@ -1,55 +1,266 @@
 <template>
   <div>
-    <el-container>
-      <el-aside width="200px">
-        <div class="JKWTree-tree">
-          <h3>产品品质统计数据</h3>
-          <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
-        </div>
-      </el-aside>
-      <el-container>
-		  
-        <el-main>
-
-        </el-main>
-      </el-container>
-    </el-container>
+    <Layout>
+      <LayoutHeader>
+        <el-form inline>
+          <el-form-item>
+            <el-button type="primary" icon="Download" @click="exportDetail" style="margin: 5px;float: right;">导出到Excel(明细)</el-button>
+            <el-button type="primary" icon="Download" @click="exportSummary" style="margin: 5px;float: right;">导出到Excel(汇总)</el-button>
+          </el-form-item>
+        </el-form>
+      </LayoutHeader>
+
+      <Layout>
+        <LayoutSider :width="280" style="background:#fff;border-right:1px solid #e5e6eb;overflow:auto;">
+          <div style="padding:12px 14px;font-size:14px;font-weight:600;color:#1d2129;border-bottom:1px solid #f0f0f0;">
+            产品品质统计数据
+          </div>
+          <el-tree
+            :data="treeData"
+            highlight-current
+            node-key="key"
+            :expand-on-click-node="false"
+            :props="{ label: 'label', children: 'children' }"
+            @node-click="handleNodeClick"
+          />
+        </LayoutSider>
+
+        <LayoutContent style="padding:12px;overflow:auto;background:#f5f6f7;">
+          <!-- 上方:按产品合计 -->
+          <div style="background:#fff;border:1px solid #e5e6eb;border-radius:4px;margin-bottom:10px;">
+            <div style="padding:8px 14px;font-size:14px;font-weight:600;color:#1d2129;border-bottom:1px solid #f0f0f0;">
+              产品品质合计
+              <span style="margin-left:10px;font-size:12px;color:#909399;font-weight:400;">
+                {{ currentNodeLabel || '(请在左侧选择年/月/厂商)' }}
+              </span>
+            </div>
+            <el-table
+              :data="tableData1"
+              row-key="产品代号"
+              highlight-current-row
+              border
+              style="width:100%;height:34vh;"
+              :row-style="{ height:'24px' }"
+              :cell-style="{ padding:'0px' }"
+              :header-row-style="{ height:'24px' }"
+              :header-cell-style="{ padding:'4px 0' }"
+              show-overflow-tooltip="true"
+              empty-text="暂无数据"
+              @row-click="onProductClick"
+            >
+              <el-table-column v-for="col in tableCols1" :key="col.prop"
+                :prop="col.prop" :label="col.label" :width="col.width"
+                align="center"
+              />
+            </el-table>
+          </div>
+
+          <!-- 下方:单产品工单明细 -->
+          <div style="background:#fff;border:1px solid #e5e6eb;border-radius:4px;">
+            <div style="padding:8px 14px;font-size:14px;font-weight:600;color:#1d2129;border-bottom:1px solid #f0f0f0;">
+              工单明细
+              <span style="margin-left:10px;font-size:12px;color:#909399;font-weight:400;">
+                {{ currentProduct?.['产品代号']
+                  ? currentProduct['产品代号'] + ' ' + (currentProduct['产品名称'] || '')
+                  : '(请先在上方选择一行产品)' }}
+              </span>
+            </div>
+            <el-table
+              :data="tableData2"
+              border
+              style="width:100%;height:40vh;"
+              :row-style="{ height:'24px' }"
+              :cell-style="{ padding:'0px' }"
+              :header-row-style="{ height:'24px' }"
+              :header-cell-style="{ padding:'4px 0' }"
+              show-overflow-tooltip="true"
+              empty-text="暂无工单明细"
+            >
+              <el-table-column v-for="col in tableCols2" :key="col.prop"
+                :prop="col.prop" :label="col.label" :width="col.width"
+                :min-width="col.minWidth" align="center"
+              />
+            </el-table>
+          </div>
+        </LayoutContent>
+      </Layout>
+    </Layout>
   </div>
 </template>
+
 <script setup>
-import {
-  getDepartment,
-  getMachineInfo
-} from '@/api/mes/job'
-import {
-  createCompany,
-  deleteCompany,
-  deleteCompanyByIds,
-  updateCompany,
-  findCompany,
-  getCompanyList
-} from '@/api/company'
-// 全量引入格式化工具 请按需保留
-import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
-import { ElMessage, ElMessageBox } from 'element-plus'
-import { ref, reactive } from 'vue'
-import { useUserStore } from '@/pinia/modules/user'
-const userStore = useUserStore()
-const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
-defineOptions({
-    name: 'Company'
+import { ElMessage } from 'element-plus'
+import { Download } from '@element-plus/icons-vue'
+import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue'
+import { ref } from 'vue'
+import * as XLSX from 'xlsx'
+import { getProductQualityTab, getProductQualityList } from '@/api/mes_api_gty/orderAccounting'
+
+defineOptions({ name: 'Productquality' })
+
+// ========== 左侧树:年 → 月 → 厂商 ==========
+const treeData = ref([])
+const loadTree = async () => {
+  const res = await getProductQualityTab()
+  if (res.code !== 0 || !Array.isArray(res.data)) return
+  treeData.value = res.data.map((yearItem) => ({
+    key: `y-${yearItem.year}`,
+    label: `${yearItem.year}年 (工单数:${yearItem.total})`,
+    nodeType: 'year',
+    year: yearItem.year,
+    month: '',
+    customer: '',
+    children: (yearItem.months || []).map((monthItem) => ({
+      key: `m-${yearItem.year}-${monthItem.month}`,
+      label: `${parseInt(monthItem.month, 10)}月 (工单数:${monthItem.total})`,
+      nodeType: 'month',
+      year: yearItem.year,
+      month: monthItem.month,
+      customer: '',
+      children: (monthItem.customers || []).map((c) => ({
+        key: `c-${yearItem.year}-${monthItem.month}-${c['客户编号'] || 'none'}`,
+        label: `${c['客户编号'] || '未匹配'}【${c['客户名称']}】(工单数:${c.total})`,
+        nodeType: 'customer',
+        year: yearItem.year,
+        month: monthItem.month,
+        customer: c['客户编号'] || '__NONE__',
+      }))
+    }))
+  }))
+}
+loadTree()
+
+// ========== 上方:按产品合计 ==========
+const tableCols1 = [
+  { label: '产品代号', prop: '产品代号', width: '130' },
+  { label: '产品名称', prop: '产品名称', width: '240' },
+  { label: '工单数', prop: '工单数', width: '80' },
+  { label: '入仓数量', prop: '入仓数量', width: '110' },
+  { label: '实际投料(万张)', prop: '实际投料', width: '130' },
+  { label: '废品合计', prop: '废品合计', width: '100' },
+  { label: '工单制程废', prop: '工单制程废', width: '110' },
+  { label: '工单检验废', prop: '工单检验废', width: '110' },
+  { label: '目标合格率', prop: '目标合格率', width: '110' },
+  { label: '实际合格率', prop: '实际合格率', width: '110' },
+]
+const tableData1 = ref([])
+
+// ========== 下方:单产品工单明细 ==========
+const tableCols2 = [
+  { label: '工单编号', prop: '工单编号', width: '120' },
+  { label: '印件号', prop: '印件号', width: '90' },
+  { label: '产品代号', prop: '产品代号', width: '130' },
+  { label: '产品名称', prop: '产品名称', minWidth: '240' },
+  { label: '入仓日期', prop: '入仓日期', width: '110' },
+  { label: '入仓数量', prop: '入仓数量', width: '110' },
+  { label: '实际投料(万张)', prop: '实际投料', width: '130' },
+  { label: '废品合计', prop: '废品合计', width: '100' },
+  { label: '工单制程废', prop: '工单制程废', width: '110' },
+  { label: '工单检验废', prop: '工单检验废', width: '110' },
+  { label: '目标合格率', prop: '目标合格率', width: '110' },
+  { label: '实际合格率', prop: '实际合格率', width: '110' },
+]
+const tableData2 = ref([])
+
+const currentNode = ref(null)
+const currentNodeLabel = ref('')
+const currentProduct = ref(null)
+
+const queryParams = () => ({
+  year: currentNode.value?.year || '',
+  month: currentNode.value?.month || '',
+  customer: currentNode.value?.customer || '',
 })
 
-</script>
+// 需要保留 2 位小数的字段(合计/明细通用)
+const NUM_FIELDS_2 = ['入仓数量', '实际投料', '废品合计', '工单制程废', '工单检验废', '计划损耗']
+// 强制整数的字段
+const NUM_FIELDS_INT = ['工单数']
 
-<style>
-.JKWTree-container {
-  display: flex;
+const roundRow = (row) => {
+  const out = { ...row }
+  NUM_FIELDS_2.forEach(f => {
+    if (out[f] !== undefined && out[f] !== null && out[f] !== '' && typeof out[f] !== 'string') {
+      out[f] = Number(Number(out[f]).toFixed(2))
+    }
+  })
+  NUM_FIELDS_INT.forEach(f => {
+    if (out[f] !== undefined && out[f] !== null && out[f] !== '' && typeof out[f] !== 'string') {
+      out[f] = Math.round(Number(out[f]))
+    }
+  })
+  return out
+}
+
+// 左侧节点点击 → 按产品合计
+const handleNodeClick = async (node) => {
+  currentNode.value = node
+  currentNodeLabel.value = node.label
+  currentProduct.value = null
+  tableData2.value = []
+
+  const res = await getProductQualityList(queryParams())
+  if (res.code === 0) {
+    tableData1.value = (res.data?.summary || []).map(roundRow)
+  } else {
+    tableData1.value = []
+    ElMessage.warning(res.msg || '查询产品品质数据失败')
+  }
+}
+
+// 点击上方产品行 → 该产品的工单明细
+const onProductClick = async (row) => {
+  currentProduct.value = row
+  const res = await getProductQualityList({
+    ...queryParams(),
+    cpdh: row['产品代号']
+  })
+  if (res.code === 0) {
+    tableData2.value = (res.data?.detail || []).map(roundRow)
+  } else {
+    tableData2.value = []
+    ElMessage.warning(res.msg || '查询工单明细失败')
+  }
+}
+
+// 通用:把列配置 + 数据 → 导出 Excel
+const exportColsToXlsx = (cols, data, filename, sheetName = 'Sheet1') => {
+  if (!data || data.length === 0) {
+    ElMessage.warning('当前没有可导出的数据')
+    return
+  }
+  const headerMap = {}
+  const fields = []
+  cols.forEach(c => {
+    if (!c.prop) return
+    headerMap[c.prop] = c.label
+    fields.push(c.prop)
+  })
+  const rows = data.map(r => {
+    const out = {}
+    fields.forEach(f => { out[headerMap[f]] = r[f] })
+    return out
+  })
+  const ws = XLSX.utils.json_to_sheet(rows)
+  // 粗略设置列宽
+  ws['!cols'] = fields.map(f => ({ wch: Math.max(8, String(headerMap[f]).length * 1.5) }))
+  const wb = XLSX.utils.book_new()
+  XLSX.utils.book_append_sheet(wb, ws, sheetName)
+  XLSX.writeFile(wb, filename)
+}
+
+// 导出汇总(上方表格)
+const exportSummary = () => {
+  exportColsToXlsx(tableCols1, tableData1.value, `产品品质合计_${currentNodeLabel.value || '全部'}.xlsx`, '产品品质合计')
 }
-/* 选中某行时的背景色*/
-.el-table__body tr.current-row>td {
-  background: #ff80ff !important;
+
+// 导出明细(下方表格)
+const exportDetail = () => {
+  exportColsToXlsx(tableCols2, tableData2.value, `工单明细_${currentProduct.value?.['产品代号'] || '全部'}.xlsx`, '工单明细')
 }
+</script>
+
+<style>
 .JKWTree-tree {
   width: 300px;
   background-color: #fff;
@@ -62,8 +273,4 @@ defineOptions({
   font-weight: 700;
   margin: 10px 0;
 }
-
-.JKWTree-content {
-  flex: 1;
-}
 </style>

+ 31 - 2
src/view/quality/management.vue

@@ -13,10 +13,10 @@
           <el-table ref="multipleTable" style="width: 100%;height: 70vh" tooltip-effect="dark"
                     :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                     :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
-                    :data="tableData"  border row-key="工单编号"
+                    :data="tableData"  border row-key="提交时间"
                     size="small"
                     highlight-current-row="true"
-                    @row-click="tableRowClick" :show-overflow-tooltip="true">
+                    @row-click="tableRowClick" @row-dblclick="tableRowDblclick" :show-overflow-tooltip="true">
             <el-table-column  sortable align="center" label="类别" prop="类别"  width="120" />
             <el-table-column  sortable align="center" label="工单编号" prop="工单编号"  width="120" />
             <el-table-column  sortable align="center" label="印件号" prop="印件号"  width="100" />
@@ -30,6 +30,27 @@
         </el-main>
       </el-container>
     </el-container>
+
+	<!--巡查记录明细(双击行打开)-->
+	<el-dialog v-model="detailVisible" title="巡查记录明细" width="75%" top="10%" append-to-body>
+	  <div style="margin-bottom:8px;color:#606266;font-size:13px;">
+	    工单编号:{{ detailRow?.工单编号 || '-' }} &nbsp;|&nbsp;
+	    印件号:{{ detailRow?.印件号 || '-' }} &nbsp;|&nbsp;
+	    提交时间:{{ detailRow?.提交时间 || '-' }} &nbsp;|&nbsp;
+	    共 {{ detailRow?.items?.length || 0 }} 项
+	  </div>
+	  <el-table :data="detailRow?.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="200" />
+	    <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="detailVisible = false">关闭</el-button>
+	  </template>
+	</el-dialog>
   </div>
 </template>
 <script setup>
@@ -117,6 +138,14 @@ const tableRowClick = (row) => {
   console.log("点击的行:", row);
 };
 
+// 双击行查看该次提交的所有检验项目明细
+const detailVisible = ref(false);
+const detailRow = ref(null);
+const tableRowDblclick = (row) => {
+  detailRow.value = row;
+  detailVisible.value = true;
+};
+
 </script>
 
 <style>

+ 450 - 9
src/view/quality/orderstatus.vue

@@ -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?.工单编号 || '-' }} &nbsp;|&nbsp;
+	    流程单号:{{ zcjyjlDetailRow?.流程单号 || '-' }} &nbsp;|&nbsp;
+	    提交时间:{{ zcjyjlDetailRow?.检验时间 || '-' }} &nbsp;|&nbsp;
+	    共 {{ 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'] }} &nbsp;|&nbsp;
+	      产品名称:{{ _GetorderDetail['Gd_cpmc'] }} &nbsp;|&nbsp;
+	      共 {{ 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;
 	}

+ 92 - 16
src/view/yunyin/chanpinziliao/chanpinziliao.vue

@@ -489,7 +489,7 @@
               <el-table-column v-slot="scope"   align="left" label=新机组编号 width="115" >
                 <el-select v-model="scope.row.Gy0_sbbh" >
       <el-option
-        v-for="machine in jtList"
+        v-for="machine in (scope.row.jtList || [])"
         :key="machine"
         :label="machine.split('-->')[0].trim()"
         :value="machine.split('-->')[0].trim()"
@@ -530,6 +530,34 @@
             </el-tree>
           </el-dialog>         
 
+          <!--排产参数调整-工单影响预览-->
+          <el-dialog v-model="editPreviewListVisible" title="修改机台影响预览" width="85%" top="8%" append-to-body>
+            <div v-if="editPreviewAffected.length === 0" style="text-align:center;padding:30px;color:#909399;">
+              本次修改未涉及机台变更,或没有未开工的关联工单
+            </div>
+            <div v-else>
+              <div style="margin-bottom:10px;color:#E6A23C;font-size:14px;">
+                以下 {{ editPreviewAffected.length }} 条未开工工单的设备编号将被同步修改,请确认:
+              </div>
+              <el-table :data="editPreviewAffected" border size="small" :row-style="{ height: '26px' }" :cell-style="{ padding: '0px 8px' }">
+                <el-table-column label="工单编号" prop="gdbh" width="130" />
+                <el-table-column label="产品代号" prop="cpdh" width="120" />
+                <el-table-column label="印件号" prop="yjno" width="80" />
+                <el-table-column label="工序号" prop="gxh" width="80" />
+                <el-table-column label="原机台" prop="old_sbbh" width="130" />
+                <el-table-column label="修改后机台" prop="new_sbbh" width="130">
+                  <template #default="{ row }">
+                    <span style="color:#F56C6C;font-weight:bold;">{{ row.new_sbbh }}</span>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </div>
+            <template #footer>
+              <el-button @click="editPreviewListVisible = false">取消</el-button>
+              <el-button type="primary" @click="doEditGyAfterPreview" :loading="editPreviewSubmitting">确定修改</el-button>
+            </template>
+          </el-dialog>
+
           <!--核算参数调整-->
           <el-dialog v-model="hscstzlist" title="核算参数调整"  style="width: 100%;height: 100%;margin:  0;">
             <el-button type="" @click="hscstzCancel">取消</el-button>
@@ -1570,6 +1598,7 @@ import {
   getDepartment,
   getProduct,
   editGy,
+  editGyPreview,
   getProductData,
   getProductYjInfo,
   getGyTotal,
@@ -2393,7 +2422,6 @@ const pccstzformData = reactive({cpdh: '',});
 const cjdisplay = ref(false)
 const jtdisplay = ref(false)
 const cjList = ref([])
-const jtList = ref([])
 const selectedMachine = ref('');
 let currentRowIndex = null; // 用于存储当前行的索引
 //点击【排产参数调整】按钮
@@ -2413,26 +2441,51 @@ const pccstzProductValue = async () => {
   _product_code.value = '';
   _pccstzgetProductGy();
 };
+//按车间获取机台列表,回填到每一行(同一车间只请求一次)
+const loadMachineListBySite = async (rows) => {
+  const sites = [...new Set(rows.map(r => (r.Gy0_site || '').trim()).filter(Boolean))];
+  const siteMap = {};
+  await Promise.all(sites.map(async (site) => {
+    try {
+      const res = await gdzl_MachineList({ address: site });
+      siteMap[site] = res.data || [];
+    } catch (error) {
+      console.error('获取车间机台失败:', site, error);
+      siteMap[site] = [];
+    }
+  }));
+  rows.forEach(row => {
+    const site = (row.Gy0_site || '').trim();
+    row.jtList = site ? (siteMap[site] || []) : [];
+  });
+}
 //排产参数调整 获取单个工艺数据(排产参数调整)
 const _pccstzgetProductGy = async ()=>{
   let product_code = _product_code.value || pccstzformData['cpdh'];
   try {
     const getProductGydata = await getProductGy({product_code:product_code});
     pccstztableData.value = getProductGydata.data;
-    const formattedData = getProductGydata.data.map(item=>{
+    pccstztableData.value.forEach(item=>{
       //原A类产能
       item.old_A_power = item.A_power;
       //原损耗代号
       item.old_Gy0_shdh = item.Gy0_shdh;
       // 原机组编号
       item.old_Gy0_sbbh = item.Gy0_sbbh;
-      return item
+      item.jtList = [];
     });
+    //弹窗打开时车间已有值,直接按其自动加载对应机台列表
+    await loadMachineListBySite(pccstztableData.value);
   } catch (error) {
     console.error(error);
   }
 }
-//排产参数调整 【执行更新按钮】
+//排产参数调整 【执行更新按钮】→ 先预览影响,再确认修改
+const editPreviewListVisible = ref(false);
+const editPreviewAffected = ref([]);
+const editPreviewSubmitting = ref(false);
+const pendingEditGyData = ref(null);
+
 const pccstzConfirm = async () => {
   const rawValueArray = pccstztableData._rawValue;
   const formattedData = rawValueArray.map(item => {
@@ -2445,13 +2498,33 @@ const pccstzConfirm = async () => {
       Gy0_site: item.Gy0_site
     };
   });
-  const editGy_edit = await editGy(formattedData);
-  if (editGy_edit.code === 0) {
-    ElMessage({type: 'success',message: '更新成功'})
+  // 调预览接口,看有多少未开工工单会被影响
+  const preview = await editGyPreview(formattedData);
+  if (preview.code === 0) {
+    editPreviewAffected.value = preview.data || [];
   } else {
-    ElMessage({type: 'error',message: '更新失败'})
+    editPreviewAffected.value = [];
+  }
+  pendingEditGyData.value = formattedData;
+  editPreviewListVisible.value = true;
+};
+
+// 预览弹窗点「确定修改」→ 真正调用 editGy
+const doEditGyAfterPreview = async () => {
+  editPreviewSubmitting.value = true;
+  try {
+    const editGy_edit = await editGy(pendingEditGyData.value);
+    if (editGy_edit.code === 0) {
+      ElMessage({ type: 'success', message: '更新成功' })
+    } else {
+      ElMessage({ type: 'error', message: editGy_edit.msg || '更新失败' })
+      return;
+    }
+    editPreviewListVisible.value = false;
+    pccstzlist.value = false;
+  } finally {
+    editPreviewSubmitting.value = false;
   }
-  pccstzlist.value = false;
 };
 //排产参数调整 放弃
 const pccstzCancel = () => {pccstzlist.value = false;};
@@ -2482,12 +2555,15 @@ const apiData = await getDepartName()
 const selectHandle = async (node) => {
 const isTopLevelNode = node.label === '标准工艺';
 if (!isTopLevelNode) {
-    // 处理子节点的点击
-    pccstztableData.value[currentRowIndex].Gy0_site = node.label;
-    console.log(pccstztableData.value);
-    const MachineList_jitai = await gdzl_MachineList({ address: node.label });
-    console.log(MachineList_jitai.data);
-    jtList.value = MachineList_jitai.data;
+    const row = pccstztableData.value[currentRowIndex];
+    if (row) {
+      // 处理子节点的点击
+      row.Gy0_site = node.label;
+      const MachineList_jitai = await gdzl_MachineList({ address: node.label });
+      //机台列表按行独立存放,避免不同车间的行互相覆盖
+      row.jtList = MachineList_jitai.data || [];
+      row.Gy0_sbbh = '';
+    }
     cjdisplay.value = false;
   }
 };

+ 520 - 0
src/view/yunyin/shengchanguanli/components/gongyiziliao.vue

@@ -0,0 +1,520 @@
+<template>
+  <!-- 工艺资料弹窗(排产页面双击排程行打开,避免在两个页面间来回切换) -->
+  <el-dialog v-model="visible" :title="'工艺资料 - ' + gdbh" style="width: 96%;" top="3vh"
+             append-to-body destroy-on-close>
+    <el-table ref="multipleTable"
+              :row-style="{ height: '20px' }"
+              :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+              :header-cell-style="{ padding: '0px' }"
+              highlight-current-row
+              :show-overflow-tooltip="true"
+              size="small"
+              :cell-class-name="gysatusCellClass"
+              @row-dblclick="openEdit"
+              @row-click="gyRowClick"
+              :row-class-name="rowClassStyle2"
+              style="width: 100%;height: 60vh" border tooltip-effect="dark" :data="gytableData" row-key="ID">
+      <el-table-column type="index" width="40" />
+      <el-table-column align="left" label="完工状态" prop="status" width="73" />
+      <el-table-column align="left" label="重点工序" prop="重点工序" width="45" />
+      <el-table-column align="left" label="印件" prop="印件号" width="45" />
+      <el-table-column align="left" label="工序" prop="工序号" width="45" />
+      <el-table-column align="left" label="备选工序" prop="备选工序" width="45" />
+      <el-table-column align="left" label="工序名称" prop="工序名称" width="125" />
+      <el-table-column align="left" label="计划产量" prop="计划产量" width="73" />
+      <el-table-column align="left" label="基础损耗" prop="基础损耗" width="45" />
+      <el-table-column align="left" label="损耗率" prop="损耗率" width="70" />
+      <el-table-column align="left" label="报废定额" prop="报废定额" width="45" />
+      <el-table-column align="left" label="允损比例" prop="允损比例" width="60" />
+      <el-table-column align="left" label="难度系数" prop="难度系数" width="73" />
+      <el-table-column align="left" label="损耗系数" prop="损耗系数" width="73" />
+      <el-table-column align="left" label="人工检次品板" prop="人工检_次品板" width="70" />
+      <el-table-column align="left" label="人工检废检" prop="人工检_废检" width="70" />
+      <el-table-column align="left" label="机检正品板" prop="机检_正品板" width="70" />
+      <el-table-column align="left" label="机检次品板" prop="机检_次品板" width="70" />
+      <el-table-column align="left" label="机检废检" prop="机检_废检" width="45" />
+      <el-table-column align="center" label="开数" prop="开数" width="45" />
+      <el-table-column align="center" label="联数" prop="联数" width="45" />
+      <el-table-column align="left" label="备注" prop="备注" width="115" />
+      <el-table-column align="left" label="印刷方式" prop="印刷方式" width="80" />
+      <el-table-column align="center" label="版距" prop="版距" width="60" />
+      <el-table-column align="left" label="建档日期" prop="建档日期" width="150" />
+      <el-table-column align="left" label="建档用户" prop="建档用户" width="90" />
+      <el-table-column align="left" label="更新时间" prop="更新时间" width="150" />
+    </el-table>
+    <div style="color:#909399;font-size:12px;margin-top:6px;">双击表格行可修改工艺资料</div>
+  </el-dialog>
+
+  <!-- 修改工艺资料弹窗 -->
+  <el-dialog v-model="editVisible" :before-close="closeEdit" style="width: 1100px;" :title="'修改工艺资料'"
+             append-to-body destroy-on-close>
+    <el-form>
+      <div>
+        <div style="display: flex; gap: 0px;">
+          <el-form-item label="印件编号:" class="mab" prop="keyOrder">
+            <el-input disabled v-model="gdgyformData['印件']" style="width: 100px;" />
+          </el-form-item>
+          <el-form-item label="工序编号:" class="mab" prop="keyOrder" label-width=" 90">
+            <el-input disabled v-model="gdgyformData['工序']" style="width: 100px;" />
+          </el-form-item>
+          <el-form-item label="重点工序:" class="mab" prop="keyOrder" label-width=" 90">
+            <el-input v-model="gdgyformData['重点工序']" id="gy_重点工序" style="width: 100px;"
+                      @keydown="gyzlent($event, '', 'gy_重点工序', 'gy_设备编号')" />
+          </el-form-item>
+          <el-form-item label="备选工序:" class="mab" prop="isBanciSelected" label-width=" 90">
+            <el-checkbox v-model="gdgyformData['备选工序']"></el-checkbox>
+          </el-form-item>
+          <el-form-item label="加工开数:" class="mab" prop="keyOrder" label-width=" 125">
+            <el-input v-model="gdgyformData['开数']" style="width: 100px;" />
+          </el-form-item>
+          <el-form-item label="加工联数:" class="mab" prop="keyOrder" label-width=" 80">
+            <el-input v-model="gdgyformData['联数']" style="width: 100px;" />
+          </el-form-item>
+        </div>
+        <div style="display: flex; gap: 0px;">
+          <el-form-item label="车间名称:" class="mab" prop="keyOrder">
+            <el-input v-model="gdgyformData['车间名称']" style="width: 130px;"
+                      @keydown="gyzlent($event, 'gy_联数', 'gy_车间名称', 'gy_工序名称')" />
+          </el-form-item>
+          <el-form-item label="工艺名称:" class="mab" prop="keyOrder" label-width=" 90">
+            <el-input v-model="gdgyformData['工艺名称']" style="width: 140px;" />
+          </el-form-item>
+          <el-form-item label="工序名称:" class="mab" prop="keyOrder" label-width=" 90">
+            <el-input v-model="gdgyformData['工序名称']" id="gy_工序名称" style="width: 400px;"
+                      @keydown="gyzlent($event, 'gy_车间名称', 'gy_工序名称', 'gy_设备编号')" />
+          </el-form-item>
+          <el-form-item label="计损色数" class="mab" prop="keyOrder" label-width=" 80">
+            <el-input v-model="gdgyformData['计损色数']" style="width: 90px;" />
+          </el-form-item>
+        </div>
+        <el-form-item label="设备编号:" class="mab" prop="remark">
+          <el-select v-model="gdgyformData['设备编号']" multiple id="gy_设备编号"
+                     @keydown="gyzlent($event, 'gy_重点工序', 'gy_设备编号', 'gy_工序损耗')"
+                     style="flex: 1; height: auto;">
+            <el-option
+                @keydown.tab.prevent="sbbhclick"
+                @click="sbbhclick"
+                v-for="(item, index) in gdzl_MachineList_address.data"
+                :key="index"
+                :label="item.split('-->')[0].trim()"
+                :value="item.split('-->')[0].trim()">
+              {{ item }}
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="工序损耗:" class="mab" prop="keyOrder">
+          <el-input v-model="gdgyformData['shdh']" readonly style="width: 10%;" id="gy_工序损耗"
+                    @keydown="gyzlent($event, 'gy_设备编号', 'gy_工序损耗', 'gy_损耗系数')" />
+          <el-input v-model="gdgyformData['工序损耗名称']" style="width: 88.7%;margin-left: 10px" />
+        </el-form-item>
+        <div style="display: flex; gap: 0px;">
+          <el-form-item label="损耗系数:" class="mab" prop="keyOrder">
+            <el-input v-model="gdgyformData['损耗系数']" style="flex: 1;" id="gy_损耗系数"
+                      @keydown="gyzlent($event, 'gy_工序损耗', 'gy_损耗系数', 'gy_难度系数')" />
+          </el-form-item>
+          <el-form-item label="难度系数" class="mab" prop="keyOrder">
+            <el-input v-model="gdgyformData['难度系数']" :disabled="isDisabled" style="flex: 1;" id="gy_难度系数"
+                      @keydown="gyzlent($event, 'gy_设备编号', 'gy_难度系数', 'gy_小时产能')" />
+          </el-form-item>
+          <el-form-item label="装版工时:" class="mab" prop="keyOrder">
+            <el-input v-model="gdgyformData['辅助工时']" style="flex: 1;" />
+          </el-form-item>
+          <el-form-item label="排产小时产能:" class="mab" prop="keyOrder" label-width=" 120px">
+            <el-input v-model="gdgyformData['小时产能']" style="flex: 1;" id="gy_小时产能"
+                      @keydown="gyzlent($event, 'gy_难度系数', 'gy_小时产能', '')" />
+          </el-form-item>
+          <el-form-item label="印刷方式" class="mab" prop="keyOrder">
+            <el-input v-model="gdgyformData['印刷方式']" style="flex: 1;" />
+          </el-form-item>
+          <el-form-item label="版距" class="mab" prop="keyOrder">
+            <el-input v-model="gdgyformData['版距']" style="flex: 1;" />
+          </el-form-item>
+        </div>
+        <el-form-item label="工序备注:" class="mab" prop="remark">
+          <el-input type="textarea" resize="none" v-model="gdgyformData['备注']" rows="3" clearable
+                    style="flex: 1;resize: none" />
+        </el-form-item>
+        <el-form-item label="质量要求:" class="mab" prop="remark">
+          <el-input type="textarea" resize="none" v-model="gdgyformData['质量要求']" rows="2" clearable
+                    style="flex: 1;resize: both;" />
+        </el-form-item>
+        <el-form-item label="质量隐患:" class="mab" prop="remark">
+          <el-input type="textarea" resize="none" v-model="gdgyformData['质量隐患']" rows="2" clearable
+                    style="flex: 1;" />
+        </el-form-item>
+      </div>
+    </el-form>
+    <template #footer>
+      <div class="dialog-footer" style="text-align: right;top: auto">
+        <el-button @click="closeEdit">取 消</el-button>
+        <el-button type="primary" @click="saveEdit">确 定</el-button>
+      </div>
+    </template>
+  </el-dialog>
+
+  <!-- 车间选择 -->
+  <el-dialog v-model="cjdisplay" :before-close="()=> cjdisplay = false" style="width: 800px;" :title="'车间选择'"
+             append-to-body destroy-on-close>
+    <el-tree
+        :data="cjList"
+        :render-after-expand="false"
+        @node-click="selectHandle"
+        :props="{children: 'children',label: 'label', value: 'value'}"
+        style="border: 1px solid #ececec; padding: 10px;height: 400px;overflow: auto;"
+        node-key="value"
+    >
+    </el-tree>
+  </el-dialog>
+
+  <!-- 标准损耗列表 -->
+  <el-dialog v-model="shxsdisplay" :before-close="() => shxsdisplay = false" append-to-body>
+    <el-form>
+      <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
+        <el-tree :data="getSHListdata" :props="defaultProps" @node-click="selectSHNode" />
+      </div>
+    </el-form>
+  </el-dialog>
+</template>
+
+<script setup>
+import { ref, reactive } from 'vue'
+import { ElMessage } from 'element-plus'
+import { useUserStore } from '@/pinia/modules/user'
+import {
+  workOrderListDetail,
+  ProcessDetailEdit,
+  gdzl_MachineList,
+  getLossCode,
+  WastageList,
+  capacityList,
+  getDepartName
+} from '@/api/yunyin/yunying'
+
+defineOptions({ name: 'GongyiZiliaoDialog' })
+
+const userStore = useUserStore()
+const _username = userStore.userInfo.userName + '/' + userStore.userInfo.nickName
+
+const visible = ref(false)
+const gdbh = ref('')
+const gytableData = ref([])
+
+// 加载该工单的工艺资料
+const loadData = async () => {
+  if (!gdbh.value) return
+  const res = await workOrderListDetail({ Gd_gdbh: gdbh.value })
+  gytableData.value = (res.data && res.data.processList) || []
+}
+
+// 对外方法:打开弹窗
+const open = async (workOrderNo) => {
+  gdbh.value = workOrderNo
+  gytableData.value = []
+  visible.value = true
+  await loadData()
+}
+
+defineExpose({ open, loadData })
+
+// =============== 表格颜色 ===============
+const currentGy0_yjno = ref(null)
+const gyRowClick = (row) => {
+  const key = row['印件-工序']
+  currentGy0_yjno.value = key ? key.substr(0, 2) : null
+}
+const rowClassStyle2 = ({ row }) => {
+  const key = row['印件-工序']
+  if (key && key.substr(0, 2) === currentGy0_yjno.value) {
+    return 'warning-row'
+  }
+}
+const gysatusCellClass = ({ row }) => {
+  if (row['status'] === '未完工') return 'status-plan-usage-low'
+  if (row['status'] === '已完工') return 'statusy-plan-usage-low'
+}
+
+// =============== 修改工艺资料 ===============
+const editVisible = ref(false)
+const isDisabled = ref(false)
+const gdgyformData = reactive({})
+const gdzl_MachineList_address = reactive({ data: [] })
+const cjList = ref([])
+const cjdisplay = ref(false)
+
+// 双击行打开修改弹窗
+const openEdit = async (row) => {
+  isDisabled.value = userStore.userInfo.nickName !== '吴杏'
+
+  Object.assign(gdgyformData, row)
+  editVisible.value = true
+
+  // 车间树
+  const apiData = await getDepartName()
+  const transformDataToTreeFormat = (data) => Object.entries(data).map(([key, value]) => ({
+    label: key,
+    children: Object.entries(value).map(([workshop, operations]) => ({
+      label: workshop,
+      children: operations.map(operation => ({ label: operation, value: operation }))
+    }))
+  }))
+  cjList.value = transformDataToTreeFormat(apiData.data)
+
+  // 拆解「工序名称」→ 工艺名称 / 工序名称
+  const processName = row['工序名称'] || ''
+  let technologyName = ''
+  let operationName = ''
+  const bracketIndex = processName.indexOf('【')
+  if (bracketIndex !== -1) {
+    technologyName = processName.substring(0, bracketIndex).trim()
+    operationName = processName.substring(bracketIndex + 1, processName.indexOf('】')).trim()
+  } else {
+    technologyName = processName.trim()
+  }
+
+  // 拆解「印件-工序」→ 印件 / 工序
+  const printProcess = row['印件-工序'] || ''
+  let yinjian = ''
+  let gongxu = ''
+  const dashIndex = printProcess.indexOf('-')
+  if (dashIndex !== -1) {
+    yinjian = printProcess.substring(0, dashIndex).trim()
+    gongxu = printProcess.substring(dashIndex + 1).trim()
+  } else {
+    yinjian = printProcess.trim()
+  }
+
+  gdgyformData['印件'] = yinjian
+  gdgyformData['工序'] = gongxu
+  gdgyformData['工艺名称'] = technologyName
+  gdgyformData['工序名称'] = operationName
+  if (row['备选工序'] == 1) {
+    gdgyformData['备选工序'] = true
+  }
+
+  gdgyformData['设备编号'] = []
+  // 通过车间名称查询机台
+  const cjmc = row['车间名称'] || ''
+  const MachineList_jitai = await gdzl_MachineList({ address: cjmc })
+  if (MachineList_jitai.data === null || MachineList_jitai.data === '') {
+    ElMessage({ type: 'warning', message: '未找到该车间机台' })
+    return false
+  }
+  const jitai = (row['机台编号'] || '').split(' ')
+  jitai.forEach(item => {
+    if (item !== '' && MachineList_jitai.data.some(jt => jt.indexOf(item) > -1)) {
+      gdgyformData['设备编号'].push(item)
+    }
+  })
+  gdzl_MachineList_address.data = MachineList_jitai.data
+}
+
+// 修改工艺资料【确定】
+const saveEdit = async () => {
+  if (!gdbh.value) {
+    ElMessage({ type: 'error', message: '更新失败' })
+    return
+  }
+  const sbbh = (gdgyformData['设备编号'] || []).join(' ')
+  const formattedData = {
+    UniqId: gdgyformData['UniqId'],
+    Gy0_gdbh: gdbh.value,
+    Gy0_方案: 'A',
+    Gy0_yjno: gdgyformData['印件'] ? gdgyformData['印件'] : '',
+    Gy0_gxh: gdgyformData['工序'] ? gdgyformData['工序'] : '',
+    Gy0_gxmc: gdgyformData['工艺名称'] ? gdgyformData['工艺名称'] : '',
+    Add_gxmc: gdgyformData['工序名称'] ? gdgyformData['工序名称'] : '',
+    备选工序: gdgyformData['备选工序'] === true ? 1 : 0,
+    重点工序: gdgyformData['重点工序'] ? gdgyformData['重点工序'] : '',
+    Gy0_sbbh: sbbh,
+    Gy0_sbmc: '',
+    Gy0_SITE: gdgyformData['车间名称'] ? gdgyformData['车间名称'] : '',
+    Gy0_ks: gdgyformData['开数'] ? gdgyformData['开数'] : '',
+    Gy0_ls: gdgyformData['联数'] ? gdgyformData['联数'] : '',
+    Gy0_ms: gdgyformData['计损色数'] ? gdgyformData['计损色数'] : 0,
+    Sys_id: _username,
+    工价系数: gdgyformData['难度系数'] ? gdgyformData['难度系数'] : 0,
+    损耗系数: gdgyformData['损耗系数'] ? gdgyformData['损耗系数'] : 0,
+    Gy0_shdh: gdgyformData['shdh'] ? gdgyformData['shdh'] : '',
+    Gy0_Rate1: '',
+    Gy0_小时产能: gdgyformData['小时产能'] ? gdgyformData['小时产能'] : '',
+    Gy0_辅助工时: gdgyformData['辅助工时'] ? gdgyformData['辅助工时'] : '',
+    工序备注: gdgyformData['备注'] ? gdgyformData['备注'] : '',
+    质量要求: gdgyformData['质量要求'] ? gdgyformData['质量要求'] : '',
+    质量隐患: gdgyformData['质量隐患'] ? gdgyformData['质量隐患'] : ''
+  }
+  const res = await ProcessDetailEdit(formattedData)
+  if (res.code === 0) {
+    ElMessage({ type: 'success', message: '更新成功' })
+    editVisible.value = false
+    gdgyformData['设备编号'] = []
+    await loadData()
+  } else {
+    ElMessage({ type: 'error', message: '更新失败' })
+  }
+}
+
+// 关闭修改弹窗
+const closeEdit = () => {
+  gdgyformData['设备编号'] = []
+  editVisible.value = false
+}
+
+// =============== 弹窗内交互 ===============
+const shxsdisplay = ref(false)
+const getSHListdata = ref([])
+const defaultProps = { children: 'children', label: 'label', value: 'value' }
+
+// 点击设备编号 → 带出小时产能
+const sbbhclick = () => {
+  _capacityList()
+}
+const _capacityList = async () => {
+  if (!gdgyformData['设备编号'] || gdgyformData['设备编号'].length === 0) {
+    return false
+  }
+  const machine = gdgyformData['设备编号'].join(' ')
+  const res = await capacityList({ machine })
+  gdgyformData['小时产能'] = res.data
+}
+
+// 键盘 Tabs/回车/上下左右跳转
+const gyzlent = (event, id1, id2, id3) => {
+  if ((id2 === 'gy_车间名称' && event.key === 'Tab') || (id2 === 'gy_车间名称' && event.key === 'Enter')) {
+    document.getElementById(id3).focus()
+    cjdisplay.value = true
+  }
+  if ((id2 === 'gy_工序损耗' && event.key === 'Tab') || (id2 === 'gy_工序损耗' && event.key === 'Enter')) {
+    if (gdgyformData['车间名称']) {
+      getGxshList()
+      _getSH()
+      shxsdisplay.value = true
+    }
+  }
+  if ((id2 === 'gy_工序名称' && event.key === 'Tab') || (id2 === 'gy_工序名称' && event.key === 'Enter')) {
+    if (gdgyformData['工艺名称'] === undefined) {
+      gdgyformData['工艺名称'] = ''
+    }
+    if (gdgyformData['工序名称'] === undefined) {
+      gdgyformData['工序名称'] = ''
+    }
+    gdgyformData['工序损耗名称'] = `${gdgyformData['工艺名称']} ${gdgyformData['工序名称']}`
+  }
+  if (event.keyCode === 13 || event.keyCode === 40) {
+    if (id3 != '') document.getElementById(id3).focus()
+  } else if (event.keyCode === 38) {
+    if (id1 != '') document.getElementById(id1).focus()
+  } else if (event.keyCode === 8) {
+    const el = document.getElementById(id2)
+    if (id1 != '' && el && el.value === '') document.getElementById(id1).focus()
+  } else if (event.keyCode === 37) {
+    const el = document.getElementById(id2)
+    if (id1 != '' && el && el.selectionStart == 0) document.getElementById(id1).focus()
+  } else if (event.keyCode === 39) {
+    const el = document.getElementById(id2)
+    if (id3 != '' && el && el.selectionStart == el.value.length) document.getElementById(id3).focus()
+  }
+}
+
+// 车间树点击:一级=车间名称,三级=工艺名称
+const selectHandle = async (node) => {
+  if (node.value) {
+    gdgyformData['工艺名称'] = node.value
+    gdgyformData['工序损耗名称'] = node.value
+    cjdisplay.value = false
+  } else {
+    gdgyformData['车间名称'] = node.label
+    return false
+  }
+  gdgyformData['设备编号'] = []
+  const MachineList_jitai = await gdzl_MachineList({ address: gdgyformData['车间名称'] })
+  gdzl_MachineList_address.data = MachineList_jitai.data
+  gdgyformData['shdh'] = ''
+  if (gdgyformData['工艺名称'] === undefined) gdgyformData['工艺名称'] = ''
+  if (gdgyformData['工序名称'] === undefined) gdgyformData['工序名称'] = ''
+  await InSH()
+}
+
+// 按工艺名称带出损耗代号
+const InSH = async () => {
+  if (gdgyformData['工艺名称']) {
+    const res = await getLossCode({ code: gdgyformData['工艺名称'] })
+    if (res.code === 0) {
+      gdgyformData['shdh'] = res.data[0].sys_bh
+      gdgyformData['工序损耗名称'] = `${res.data[0].sys_mc} ${gdgyformData['工序名称']}`
+      gdgyformData.损耗系数 = '1.00'
+      gdgyformData.难度系数 = '1.00'
+    }
+  }
+}
+
+// 按工艺名称查工序损耗
+const getGxshList = async () => {
+  const res = await WastageList({ process: gdgyformData.工艺名称 })
+  if (res.data === null || res.data === '') {
+    gdgyformData['shdh'] = ''
+    ElMessage({ type: 'warning', message: '未获取到工序损耗' })
+  }
+  gdgyformData['shdh'] = res.data
+}
+
+// 标准损耗树
+const _getSH = async () => {
+  const res = await getLossCode({ code: '' })
+  if (res.code === 0) {
+    const data = res.data
+    const treeData = []
+    const map = {}
+    data.forEach(item => {
+      map[item.sys_bh] = {
+        ...item,
+        children: [],
+        label: `${item.sys_bh}---${item.sys_mc}---${item.sys_rate0}---${item.sys_rate1}`
+      }
+    })
+    data.forEach(item => {
+      if (item.sys_bh.length === 3) {
+        map[item.sys_bh].level = 1
+        treeData.push(map[item.sys_bh])
+      } else {
+        map[item.sys_bh].level = 2
+        map[item.sys_bh.substring(0, 3)].children.push(map[item.sys_bh])
+      }
+    })
+    getSHListdata.value = treeData
+    shxsdisplay.value = true
+  } else {
+    console.error('获取损耗列表失败')
+  }
+}
+
+// 标准损耗树点击
+const selectSHNode = (node) => {
+  if (node.level === 2) {
+    if (gdgyformData['工艺名称'] === undefined) gdgyformData['工艺名称'] = ''
+    if (gdgyformData['工序名称'] === undefined) gdgyformData['工序名称'] = ''
+    gdgyformData['shdh'] = node.sys_bh
+    gdgyformData['工序损耗名称'] = `${node.sys_mc} ${gdgyformData['工序名称']}`
+    gdgyformData.损耗系数 = '1.00'
+    gdgyformData.难度系数 = '1.00'
+    shxsdisplay.value = false
+  }
+}
+</script>
+
+<style scoped>
+.mab {
+  margin-bottom: 6px;
+}
+:deep(.el-table__body .warning-row) {
+  background: #FFFF80 !important;
+}
+:deep(.el-table__body tr.current-row) > td {
+  background: #ff80ff !important;
+}
+:deep(.status-plan-usage-low div) {
+  color: blue !important;
+}
+:deep(.statusy-plan-usage-low div) {
+  color: #8c939d !important;
+}
+</style>

+ 13 - 0
src/view/yunyin/shengchanguanli/gongdanshengchan.vue

@@ -359,6 +359,7 @@
                         :show-overflow-tooltip="true" :row-style="{ height: '20px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :header-cell-style="{ padding: '0px' }" :highlight-current-row="true"  @row-click="chejianRowClick"
+                        @row-dblclick="chejianDblClick"
                         style="width: 100%;height: 25vh" border tooltip-effect="dark" :data="chejianData" row-key="ID" @selection-change="PC_handleChange"
               >
                 <!-- 排程列表-->
@@ -432,6 +433,7 @@
     </layout>
 
     <PrintPage ref="printPageRef" />
+    <GongyiZiliao ref="gongyiZiliaoRef" />
   </div>
 </template>
 <script>
@@ -496,6 +498,7 @@ import {
 } from "@/api/yunyin/yunying";
 
 import PrintPage from './components/print.vue'
+import GongyiZiliao from './components/gongyiziliao.vue'
 defineOptions({name: 'Company'})
 
 const printPageRef = ref()
@@ -656,6 +659,16 @@ workbenchdata();
 //全局获取工单编号
 const _Gd_gdbh = ref(null)
 const _Gd_yjno = ref(null)
+//工艺资料弹窗
+const gongyiZiliaoRef = ref()
+//双击排程列表行 打开工艺资料弹窗(可直接修改工艺资料)
+const chejianDblClick = (row) => {
+  if (!row || !row.工单编号) {
+    ElMessage({ type: 'warning', message: '该行没有工单编号' })
+    return
+  }
+  gongyiZiliaoRef.value.open(row.工单编号)
+}
 //点击表格 通过上方表格【工单编号】获取下方表格数据
 const chejianRowClick = async (row) => {
   _Gd_gdbh.value = row.工单编号;

+ 388 - 18
src/view/yunyin/shengchanguanli/shebeiyunxing.vue

@@ -24,6 +24,7 @@
 		<el-button type="primary" icon="Download" class="bt"   @click="llexporttoExcel" >拉料导出Excel</el-button>
 		<el-button @click="selectSameWorkOrder" type="success">全选同工单</el-button>
 		<el-button @click="invertSelection" type="info">反选</el-button>
+		<!-- <el-button type="warning" icon="edit" @click="openCoefCheck">难度系数校验</el-button> -->
 		<!-- <el-button type="primary" @click="onClear2" >换型清场</el-button> -->
 	</header>
 	
@@ -1038,9 +1039,9 @@
 				<el-table-column align="left" label="流程" sortable prop="num"  width="80"/>
 				<el-table-column align="left" label="补产标准" prop="补产标准"  width="85"/>
 				<el-table-column align="left" label="难度系数" prop="难度系数"  width="85"/>
-				<!-- <el-table-column align="left" label="实际系数" prop="实际系数" width="90">
+				<!-- <el-table-column align="left" label="推荐系数" prop="推荐系数" width="200">
 					<template #default="scope">
-						<span>{{ scope.row.实际系数 }}</span>
+						<span>{{ scope.row.推荐系数 }}</span>
 						<el-tooltip
 							v-if="scope.row.结果"
 							:content="scope.row.结果"
@@ -1523,7 +1524,7 @@
 			  </el-col>
 			  <el-col :span="7">
 			    <el-form-item label="开工时间:" prop="flatFeed" class="mab">
-					   <el-date-picker v-model="formdata3.value.starttime" type="datetime"  format="YYYY/MM/DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" @keydown="ent1($event)" />
+					   <el-date-picker v-model="formdata3.value.开工时间" type="datetime"  format="YYYY/MM/DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" @keydown="ent1($event)" />
 			    </el-form-item>
 			  </el-col>
 				<el-col :span="5" style="margin-top:0px; margin-bottom: 1px;">
@@ -2512,6 +2513,107 @@
 		  :formData="formData"
 		  @navigate-back="handleNavigateBack"
 		  @xuncha-visible="handleXunchaVisible" />
+
+		<!-- 难度系数校验弹窗 -->
+		<el-dialog
+		  v-model="coefCheckVisible"
+		  title="难度系数校验(近30天)"
+		  destroy-on-close
+		  width="1420px"
+		  top="3vh"
+		  :close-on-click-modal="false"
+		>
+			<div style="margin-bottom: 10px;">
+				<el-button type="primary" :disabled="coefSelection.length === 0" @click="coefBatchFix">
+					修正选中({{ coefSelection.length }}组/{{ coefSelectionTotalCount }})
+				</el-button>
+				<span style="margin-left: 12px; color: #909399; font-size: 13px;">
+					相同机台+产品名称+工序+班组+组员 的合并为一行
+				</span>
+			</div>
+			<div style="display: flex; height: calc(88vh - 130px); border: 1px solid #ebeef5;">
+				<!-- 左侧车间日期树 -->
+				<div style="flex: 0 0 220px; border-right: 1px solid #ebeef5; overflow-y: auto; padding: 6px 0;">
+					<el-tree
+						ref="coefTreeRef"
+						:data="coefTreeData"
+						:props="{ label: 'label', children: 'children' }"
+						highlight-current
+						expand-on-click-node
+						@node-click="coefNodeClick"
+					/>
+				</div>
+				<!-- 右侧表格 -->
+				<div style="flex: 1; overflow: hidden;">
+					<el-table
+						ref="coefTableRef"
+						:data="coefMergedData"
+						row-key="mergeKey"
+						border
+						height="100%"
+						:show-overflow-tooltip="true"
+						@selection-change="coefSelectionChange"
+						@row-dblclick="coefRowDblclick"
+						empty-text="请先在左侧选择日期"
+					>
+						<el-table-column type="selection" width="45" fixed="left" />
+						<el-table-column label="机台" prop="机台编号" width="110" fixed="left" />
+						<el-table-column label="产品名称" prop="产品名称" min-width="260" show-overflow-tooltip />
+						<el-table-column label="工序" prop="工序" width="130" />
+						<el-table-column label="班组" prop="bzdh" width="75" align="center" />
+						<el-table-column label="难度系数" prop="难度系数" width="110" align="center" />
+						<el-table-column label="推荐系数" prop="推荐系数" width="110" align="center">
+							<template #default="scope">
+								<span>{{ scope.row.推荐系数 || '' }}</span>
+								<el-tooltip v-if="scope.row.审核备注" :content="scope.row.审核备注" placement="top">
+									<span style="margin-left: 4px;">{{ scope.row.审核标识 }}</span>
+								</el-tooltip>
+							</template>
+						</el-table-column>
+						<el-table-column label="组员" prop="组员文本" min-width="300" show-overflow-tooltip />
+						<el-table-column label="条数" prop="count" width="70" align="right" fixed="right">
+							<template #default="scope">
+								<el-tag size="small" :type="scope.row.count > 1 ? 'warning' : 'info'">{{ scope.row.count }}</el-tag>
+							</template>
+						</el-table-column>
+					</el-table>
+				</div>
+			</div>
+			<template #footer>
+				<el-button @click="coefCheckVisible = false">关闭</el-button>
+			</template>
+		</el-dialog>
+
+		<!-- 难度系数校验 - 合并行明细弹窗 -->
+		<el-dialog
+		  v-model="coefDetailVisible"
+		  :title="'合并明细 · ' + (coefDetailRow ? (coefDetailRow.机台编号 + ' | ' + coefDetailRow.产品名称) : '')"
+		  width="1100px"
+		  top="8vh"
+		  append-to-body
+		  destroy-on-close
+		>
+			<div v-if="coefDetailRow" style="margin-bottom: 10px; padding: 8px 12px; background: #f5f7fa; border-radius: 4px; font-size: 13px; line-height: 1.8;">
+				<div><b>工序:</b>{{ coefDetailRow.工序 }} <b>班组:</b>{{ coefDetailRow.bzdh }} <b>条数:</b>{{ coefDetailRow.count }}</div>
+				<div><b>难度系数:</b>{{ coefDetailRow.难度系数 }} <b>推荐系数:</b>{{ coefDetailRow.推荐系数 }}</div>
+				<div><b>组员:</b>{{ coefDetailRow.组员文本 }}</div>
+			</div>
+			<el-table :data="coefDetailList" border size="small" height="60vh" row-key="UniqId">
+				<!-- <el-table-column label="UniqId" prop="UniqId" width="170" /> -->
+				<el-table-column label="工单" prop="工单编号" width="140" />
+				<el-table-column label="机台" prop="机台编号" width="100" />
+				<el-table-column label="工序" prop="工序" width="120" />
+				<el-table-column label="班组" prop="bzdh" width="70" align="center" />
+				<el-table-column label="难度系数" prop="难度系数" width="120" align="center" />
+				<el-table-column label="推荐系数" prop="推荐系数" width="90" align="center" />
+				<el-table-column label="组员" prop="组员文本" min-width="240" show-overflow-tooltip />
+				<el-table-column label="审核结果" prop="结果" min-width="160" show-overflow-tooltip />
+			</el-table>
+			<template #footer>
+				<el-button @click="coefDetailVisible = false">关闭</el-button>
+			</template>
+		</el-dialog>
+
         </el-main>
       </el-container>
     </el-container>
@@ -2577,6 +2679,8 @@ import {
    RemodelDetail,
    AdditionalInspectionRecordAdd,
    ProcessInspectionRecordsItemAdd,
+   getCoefTab,
+   getCoefList,
    CoefficientEdit,
    ChromaDataEdit,
    PrintingModeDataEdit,
@@ -2629,7 +2733,7 @@ import * as XLSX from 'xlsx'
 import FileSaver from 'file-saver'
 import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
-import { ref, reactive,watch,onMounted, registerRuntimeCompiler } from 'vue'
+import { ref, reactive, computed, watch, onMounted, registerRuntimeCompiler } from 'vue'
 import { useUserStore } from '@/pinia/modules/user'
 import PrintPage from './components/print.vue'
 import Onderstatus from '@/view/quality/orderstatus.vue'
@@ -2665,8 +2769,270 @@ const getResultMarker = (result) => {
 	if (!result) return ''
 	const text = String(result)
 	const m = text.match(/^([\u{1F000}-\u{1FAFF}\u2700-\u27BF\u2600-\u26FF\u2B00-\u2BFF✓✔✗×☑])/u)
-	return m ? m[1] : text.charAt(0)
+	if (m) return m[1]
+	// 库里存的审核结果可能不含图标,按文字兜底
+	if (text.indexOf('通过') > -1) return '✅'
+	if (text.indexOf('不符') > -1 || text.indexOf('异常') > -1) return '❌'
+	return ''
+}
+
+// 工价系数不符合的数据(已修正、色数异常都不算,色数异常属于色数问题不在工价系数修正范围)
+const mismatchRows = computed(() => {
+	const list = gytableData.value || []
+	return list.filter(row => {
+		if (row.isTotal || !row.UniqId) return false
+		const result = String(row.结果 || '')
+		if (!result) return false
+		if (result.indexOf('已修正') > -1) return false
+		if (result.indexOf('色数异常') > -1) return false
+		if (result.indexOf('通过') > -1) return false
+		return getResultMarker(result) === '❌'
+	})
+})
+
+// 难度系数形如 “基础系数x难度系数” 或只有基础系数,取 x 前的基础系数
+const parseBaseWageCoef = (value) => {
+	if (!value) return 0
+	const text = String(value).trim()
+	const idx = text.toLowerCase().indexOf('x')
+	const base = idx > -1 ? text.slice(0, idx) : text
+	const num = parseFloat(base)
+	return isFinite(num) && num > 0 ? num : 0
+}
+
+// 一键修正:工价系数 = 推荐系数 / 基础系数,按计算结果分组批量调用 CoefficientEdit
+const handleBatchFixCoef = async () => {
+	if (!mismatchRows.value.length) return
+	const groups = {}
+	let skipped = 0
+	mismatchRows.value.forEach(row => {
+		const suggested = parseFloat(row.推荐系数)
+		const base = parseBaseWageCoef(row.难度系数)
+		if (!isFinite(suggested) || suggested <= 0 || base <= 0) {
+			skipped++
+			return
+		}
+		const target = (suggested / base).toFixed(3)
+		if (!groups[target]) groups[target] = []
+		groups[target].push(row.UniqId)
+	})
+	const targets = Object.keys(groups)
+	if (!targets.length) {
+		ElMessage.warning('没有可修正的数据(缺少推荐系数或基础系数)')
+		return
+	}
+	const total = targets.reduce((sum, t) => sum + groups[t].length, 0)
+	let tip = `将按推荐系数修正 ${total} 条数据的工价系数,是否继续?`
+	if (skipped > 0) tip += `(另有 ${skipped} 条缺少推荐系数或基础系数,已跳过)`
+	try {
+		await ElMessageBox.confirm(tip, '一键修正确认', { type: 'warning' })
+	} catch (e) {
+		return
+	}
+	let fail = 0
+	for (const target of targets) {
+		const res = await CoefficientEdit({ id: groups[target].join(','), 工价系数: target })
+		if (res.code !== 0) fail++
+	}
+	if (fail > 0) {
+		ElMessage.error(`修正失败 ${fail} 组,请重试`)
+	} else {
+		ElMessage.success(`修正成功 ${total} 条`)
+	}
+	FacilitychanLiang()
 }
+
+/* ========== 难度系数校验弹窗相关 ========== */
+const coefCheckVisible = ref(false)
+const coefTreeRef = ref(null)
+const coefTableRef = ref(null)
+const coefTreeData = ref([])           // 左侧车间日期树
+const coefRawData = ref([])            // 当前日期的原始数据
+const coefMergedData = ref([])         // 合并后的表格数据
+const coefSelection = ref([])           // 选中的合并行
+const coefCurrentDate = ref('')         // 当前选中的日期
+// 明细弹窗
+const coefDetailVisible = ref(false)
+const coefDetailRow = ref(null)
+const coefDetailList = ref([])
+// 选中的合并行包含的总原始条数
+const coefSelectionTotalCount = computed(() => {
+	return coefSelection.value.reduce((sum, row) => sum + (row.ids ? row.ids.length : 0), 0)
+})
+
+// 打开难度系数校验弹窗
+const openCoefCheck = async () => {
+	coefCheckVisible.value = true
+	coefMergedData.value = []
+	coefSelection.value = []
+	coefCurrentDate.value = ''
+	try {
+		const res = await getCoefTab()
+		if (res.code === 0 && res.data) {
+			coefTreeData.value = Object.keys(res.data).map(workshop => ({
+				label: workshop,
+				level: 1,
+				children: res.data[workshop].map(date => ({
+					label: date,
+					date: date,
+					level: 2,
+				}))
+			}))
+		} else {
+			coefTreeData.value = []
+		}
+	} catch (e) {
+		ElMessage.error('获取车间日期数据失败')
+	}
+}
+
+// 树节点点击(ElementUI node-click 参数顺序是 data, node, component)
+const coefNodeClick = async (data, node) => {
+	// level 1 是车间,不请求数据
+	if (data.level === 1) return
+	if (!data.date) return
+	coefCurrentDate.value = data.date
+	try {
+		const res = await getCoefList({ date: data.date })
+		if (res.code === 0) {
+			coefRawData.value = res.data || []
+			coefMergeAndShow()
+		} else {
+			coefRawData.value = []
+			coefMergedData.value = []
+		}
+	} catch (e) {
+		ElMessage.error('获取数据失败')
+	}
+}
+
+// 数据合并:相同 机台编号+产品名称+工序+班组+组员编码集合 的合并为一条
+const coefMergeAndShow = () => {
+	const raw = coefRawData.value || []
+	const groups = {}
+	raw.forEach(row => {
+		const memberKey = (row['组员编码'] || []).slice().sort().join(',')
+		const key = [
+			row['机台编号'] || '',
+			row['产品名称'] || '',
+			row['工序'] || '',
+			row['bzdh'] || '',
+			memberKey,
+		].join('||')
+
+		if (!groups[key]) {
+			groups[key] = {
+				mergeKey: key,
+				机台编号: row['机台编号'] || '',
+				产品名称: row['产品名称'] || '',
+				工序: row['工序'] || '',
+				bzdh: row['bzdh'] || '',
+				难度系数: row['难度系数'] || '',
+				推荐系数: row['推荐系数'] || '',
+				组员文本: row['组员文本'] || '',
+				组员编码: row['组员编码'] || [],
+				ids: [],
+				count: 0,
+				审核结果: row['结果'] || '',
+				推荐系数组: [],
+			}
+		}
+		if (row['UniqId']) {
+			groups[key].ids.push(row['UniqId'])
+			groups[key].count++
+		}
+		if (row['推荐系数']) {
+			groups[key].推荐系数组.push(row['推荐系数'])
+		}
+		if (!groups[key].审核结果 && row['结果']) {
+			groups[key].审核结果 = row['结果']
+		}
+	})
+
+	const list = Object.values(groups)
+	list.forEach(item => {
+		if (!item.推荐系数 && item.推荐系数组.length) {
+			item.推荐系数 = item.推荐系数组[0]
+		}
+		item.审核标识 = getResultMarker(item.审核结果)
+		item.审核备注 = (item.审核结果 || '').replace(/^[\u{1F000}-\u{1FAFF}\u2700-\u27BF\u2600-\u26FF\u2B00-\u2BFF✓✔✗×☑]+/u, '').trim()
+	})
+
+	// 过滤无推荐系数的数据,按机台+条数倒序
+	coefMergedData.value = list
+		.filter(item => item.推荐系数)
+		.sort((a, b) => (b.count - a.count) || (a.机台编号 || '').localeCompare(b.机台编号 || ''))
+	coefSelection.value = []
+}
+
+// 勾选变化
+const coefSelectionChange = (rows) => {
+	coefSelection.value = rows || []
+}
+
+// 双击合并行 → 弹出明细
+const coefRowDblclick = (row) => {
+	if (!row || !row.ids || row.ids.length === 0) return
+	coefDetailRow.value = row
+	// 用 ids 从 coefRawData 反查原始记录
+	const idSet = new Set(row.ids)
+	coefDetailList.value = (coefRawData.value || []).filter(r => idSet.has(r.UniqId))
+	coefDetailVisible.value = true
+}
+
+// 批量修正选中的合并行
+const coefBatchFix = async () => {
+	if (coefSelection.value.length === 0) return
+
+	// 按推荐系数分组
+	const groups = {}
+	let totalCount = 0
+	coefSelection.value.forEach(row => {
+		if (!row.推荐系数) return
+		const targetCoef = (parseFloat(row.推荐系数) || 0).toFixed(3)
+		if (targetCoef <= 0) return
+		if (!groups[targetCoef]) groups[targetCoef] = []
+		groups[targetCoef].push(...row.ids)
+		totalCount += row.ids.length
+	})
+
+	const targets = Object.keys(groups)
+	if (!targets.length) {
+		ElMessage.warning('选中的数据缺少有效的推荐系数')
+		return
+	}
+
+	let tip = `将修正 ${coefSelection.value.length} 组合并行数据,共 ${totalCount} 条原始记录,按推荐系数 ${targets.join('、')} 修正工价系数,是否继续?`
+	try {
+		await ElMessageBox.confirm(tip, '修正确认', { type: 'warning' })
+	} catch (e) {
+		return
+	}
+
+	let fail = 0
+	for (const target of targets) {
+		const ids = [...new Set(groups[target])]
+		const res = await CoefficientEdit({ id: ids.join(','), 工价系数: target })
+		if (res.code !== 0) fail++
+	}
+
+	if (fail > 0) {
+		ElMessage.error(`修正失败 ${fail} 组,请重试`)
+	} else {
+		ElMessage.success(`修正成功 ${totalCount} 条`)
+	}
+	// 刷新弹窗内的数据和主表格
+	if (coefCurrentDate.value) {
+		const res = await getCoefList({ date: coefCurrentDate.value })
+		if (res.code === 0) {
+			coefRawData.value = res.data || []
+			coefMergeAndShow()
+		}
+	}
+	FacilitychanLiang()
+}
+/* ========== 难度系数校验弹窗 结束 ========== */
+
 const drzcDatas =ref([])
 const detailData = reactive([])
 const treeData=ref([])
@@ -4179,14 +4545,14 @@ const onADD = async() => {
 	  	 formdata3.value.yjmc=response.data.印件名称
 	  	 formdata3.value.rq=date
 	  	 if (formdata3.value.bzdh === 'A班') {
-	  	     formdata3.value.starttime = ''; // 清空值
+	  	     formdata3.value.开工时间 = ''; // 清空值
 	  	     setTimeout(()=>{
-	  			formdata3.value.starttime = date + " 08:30:00"; // 设置为 20:30:00
+	  			formdata3.value.开工时间 = date + " 08:30:00"; // 设置为 20:30:00
 	  	     })
 	  	 } else if (formdata3.value.bzdh === 'B班') {
-	  	     formdata3.value.starttime = ''; // 清空值
+	  	     formdata3.value.开工时间 = ''; // 清空值
 	  	     setTimeout(()=>{
-	  	     	formdata3.value.starttime = date + " 20:30:00"; // 设置为 20:30:00
+	  	     	formdata3.value.开工时间 = date + " 20:30:00"; // 设置为 20:30:00
 	  	     })
 	  	 }
 		 //部分数据置空
@@ -6299,6 +6665,7 @@ const addBz = async() => {
         });
         return;
     }
+		console.log(formDatas.value)
     
     const response = await MachineTeamAdd({
         sczl_jtbh:  selectedOption.value.split('|')[0],
@@ -6386,7 +6753,7 @@ const selectBz = async() => {
 		let sczl_bhkey=''
 		let sczl_namekey=''
     if (currentBz.value[9]) {
-      for (let i = 1; i <= 9; i++) {
+      for (let i = 1; i <= 10; i++) {
         sczl_bhkey=`sczl_bh${i}`
         sczl_namekey=`sczl_name${i}`
         formData.value[sczl_bhkey] = '';
@@ -6613,7 +6980,7 @@ const BZhandle = (val) => {
   let percentagekey = ''
   console.log(currentBz.value)
   if (currentBz.value[9]) {
-    for (let i = 1; i <= 9; i++) {
+    for (let i = 1; i <= 10; i++) {
       sczl_bhkey = `code${i}`
       sczl_namekey = `name${i}`
       percentagekey = `percentage${i}`
@@ -6674,7 +7041,7 @@ const initfordata3 = () => {
 		'gymc':'',
 		'rq':'',
 		'sczl_jtbh':'',
-		'starttime':'',
+		'开工时间':currentDates +' 08:00:00',
 		'num':'',
 		'sj1':'',
 		'色度数':'',
@@ -6756,6 +7123,8 @@ const initfordata3 = () => {
 		}
 		
 	}
+	console.log(formdata3.value)
+	
 }
 
 initfordata3()
@@ -6911,14 +7280,14 @@ const MachineChanliang = async(value) => {
 	 }
 	 
 	 if (formdata3.value.bzdh === 'A班') {
-	     formdata3.value.starttime = ''; // 清空值
+	     formdata3.value.开工时间 = ''; // 清空值
 	     setTimeout(()=>{
-			formdata3.value.starttime = date + " 08:30:00"; // 设置为 20:30:00
+			formdata3.value.开工时间 = date + " 08:30:00"; // 设置为 20:30:00
 	     })
 	 } else if (formdata3.value.bzdh === 'B班') {
-	     formdata3.value.starttime = ''; // 清空值
+	     formdata3.value.开工时间 = ''; // 清空值
 	     setTimeout(()=>{
-	     	formdata3.value.starttime = date + " 20:30:00"; // 设置为 20:30:00
+	     	formdata3.value.开工时间 = date + " 20:30:00"; // 设置为 20:30:00
 	     })
 	 }
    }
@@ -7922,7 +8291,7 @@ const handleFplbClickedit = (nodeData, node, component) => {
 		sczl_sj1:formdata3.value.sj1,
 		sczl_sj2:formdata3.value.sj2,
 		sczl_jtbh: formdata3.value.sczl_jtbh,
-		开工时间:formdata3.value.starttime,
+		开工时间:formdata3.value.开工时间,
 		码开始行:formdata3.value.码开始行,
 		码结束行:formdata3.value.码结束行,
 		sys_id:sys_id,
@@ -7945,6 +8314,7 @@ const handleFplbClickedit = (nodeData, node, component) => {
 		sczl_装版总工时: formdata3.value.装版总工时,
 		sczl_打样总工时: formdata3.value.打样总工时,
 		sczl_设备运行工时: formdata3.value.通电工时,
+		开工时间: formdata3.value.开工时间,
 		码包: formdata3.value.码包,
 		辅电表: formdata3.value.辅电表,
 		主电表:formdata3.value.主电表,
@@ -8008,7 +8378,7 @@ const handleFplbClickedit = (nodeData, node, component) => {
 	sczl_sj1:formdata3.value.sj1,
 	sczl_sj2:formdata3.value.sj2,
     sczl_jtbh: formdata3.value.sczl_jtbh,
-    开工时间:"2024-03-12 08:30:00",
+    开工时间:formdata3.value.开工时间,
     码开始行:formdata3.value.码开始行, 
     码结束行:formdata3.value.码结束行,
     sys_id:sys_id,