Browse Source

feat:质量统计,一次性合格率

lupeng 1 tháng trước cách đây
mục cha
commit
e1be203d05

+ 32 - 0
src/api/statistic/firstPassYieldData.ts

@@ -0,0 +1,32 @@
+import request from "@/utils/request";
+import { AxiosPromise } from "axios";
+
+export function getWorkShop(
+    queryParams: object
+): AxiosPromise<PageResult<any[]>> {
+  return request({
+    url: "/api/v1/quality/stat/workShop/list",
+    method: "post",
+    data: queryParams,
+  });
+}
+
+export function getWorkOrderInfo(
+    queryParams: object
+): AxiosPromise<PageResult<any[]>> {
+  return request({
+    url: "/api/v1/quality/stat/workOrderInfoRate/page",
+    method: "post",
+    data: queryParams,
+  });
+}
+
+export function getWorkInfoRate(
+    queryParams: object
+): AxiosPromise<PageResult<any[]>> {
+  return request({
+    url: "/api/v1/quality/stat/infoRate/page",
+    method: "post",
+    data: queryParams,
+  });
+}

+ 50 - 0
src/components/CrudTable/configs/tableConfig.ts

@@ -0,0 +1,50 @@
+import { useDictionaryStore } from "@/store";
+const { dicts } = useDictionaryStore();
+import dictDataUtil from "@/common/configs/dictDataUtil";
+export const tableConfig = {
+
+  WORK_ORDER: {
+    url: "/api/v1/quality/stat/workOrderInfo",
+    column: [
+      {
+        label: "批次",
+        prop: "workOrderCode",
+        width: 120,
+        search: true,
+      },
+      {
+        label: "产品编号",
+        prop: "materialCode",
+        width: 120,
+        search: true,
+      },
+      {
+        label: "产品名称",
+        prop: "materialName",
+        search: true,
+      },
+      {
+        label: "产品型号",
+        prop: "materialModel",
+        width: 120,
+        search: true,
+      },
+      {
+        label: "产线名称",
+        prop: "workshopName",
+      },
+
+      {
+        label: "创建时间",
+        prop: "created",
+        width: 120,
+      },
+
+    ],
+  },
+
+
+
+
+
+};

+ 228 - 0
src/components/CrudTable/index.vue

@@ -0,0 +1,228 @@
+<template>
+  <el-dialog
+    v-model="isShowTable"
+    :title="tableTitle"
+    width="900"
+    :before-close="handleClose"
+    :append-to-body="true"
+  >
+    <avue-crud
+      ref="crudRef"
+      v-model:search="search"
+      v-model="form"
+      :data="data"
+      :option="option"
+      v-model:page="page"
+      @row-click="rowClick"
+      @row-save="createRow"
+      @row-update="updateRow"
+      @row-del="deleteRow"
+      @search-change="searchChange"
+      @search-reset="resetChange"
+      @size-change="dataList"
+      @current-change="dataList"
+      @selection-change="selectionChange"
+    />
+
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button @click="handleClose">取消</el-button>
+        <el-button type="primary" @click="onSelected"> 确定 </el-button>
+      </div>
+    </template>
+  </el-dialog>
+</template>
+<script setup>
+import { ref, getCurrentInstance } from "vue";
+import { useCrud } from "@/hooks/userCrud";
+import { tableConfig } from "./configs/tableConfig";
+
+const props = defineProps({
+  tableTitle: {
+    default: "",
+    type: String,
+  },
+  tableType: {
+    default: "",
+    type: String,
+  },
+  multiple: {
+    default: false,
+    type: Boolean,
+  },
+  // 用于多选的返回值
+  multipleKey: {
+    default: "id",
+    type: String,
+  },
+  multipleRow: {
+    default: false,
+    type: Boolean,
+  },
+});
+
+const isShowTable = ref(false);
+const startSelect = async (param) => {
+  if (param) {
+    commonConfig.value.params = param;
+  }
+  dataList();
+  isShowTable.value = true;
+};
+
+/**
+ * propName 要跟字典配置的key一致
+ * dictData 字典数据, 注意props的value和label
+ * */
+const refreshDictData = (propName, dictData, keyName = "value") => {
+  nextTick(() => {
+    if (dictData && dictData.length > 0 && crudRef.value) {
+      crudRef.value.updateDic(propName, dictData);
+      search.value[propName] = dictData[0][keyName];
+    }
+  });
+};
+
+/**
+ * op 对象的字段要跟option实际字段一直 才能进行合并操作
+ */
+const mergeOption = (op) => {
+  for (const key of Object.keys(op)) {
+    option.value[key] = op[key];
+  }
+};
+
+// 传入一个url,后面不带/
+const {
+  url,
+  form,
+  data,
+  option,
+  search,
+  page,
+  toDeleteIds,
+  selectedRows,
+  Methords,
+  Utils,
+  commonConfig,
+} = useCrud({
+  src: tableConfig[props.tableType].url,
+  multipleSelectKey: props.multipleKey,
+});
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
+  Methords; //增删改查
+const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
+
+const crudRef = ref(null); //crudRef.value 获取avue-crud对象
+
+const commonTableEmits = defineEmits(["selectedSure", "selectMultipleSure"]);
+
+const calculateColumnWidth = (column) => {
+  if (!column.label) {
+    return column.minWidth;
+  }
+  // 字宽度
+  const fontSize = 17;
+  let width = fontSize * (column.label.length + 2);
+  // 如果开启过滤
+  if (column.filters) {
+    width += 12;
+  }
+  // 如果开启排序
+  if (column.sortable) {
+    width += 24;
+  }
+  return width;
+};
+
+onMounted(() => {
+  url.value = tableConfig[props.tableType].url;
+  option.value = Object.assign(option.value, {
+    searchEnter: true,
+    menu: false,
+    highlightCurrentRow: true,
+    selection: props.multiple,
+    addBtn: false,
+    height: "500",
+    overHidden: true,
+    indexWidth: "120px",
+    searchLabelWidth: "120px",
+    column: tableConfig[props.tableType].column,
+  });
+  // 列处理
+  if (option.value.column) {
+    for (let col of option.value.column) {
+      col.minWidth = calculateColumnWidth(col);
+    }
+  }
+  // dataList();
+});
+watch(
+  () => props.tableType,
+  () => {
+    url.value = tableConfig[props.tableType].url;
+    option.value = Object.assign(option.value, {
+      searchEnter: true,
+      menu: false,
+      highlightCurrentRow: true,
+      selection: props.multiple,
+      addBtn: false,
+      height: "500",
+      overHidden: true,
+      searchLabelWidth: "120px",
+      column: tableConfig[props.tableType].column,
+    });
+    // 列处理
+    if (option.value.column) {
+      for (let col of option.value.column) {
+        col.minWidth = calculateColumnWidth(col);
+      }
+    }
+    //dataList();
+  }
+);
+
+const selectRowValue = ref({});
+const rowClick = (row) => {
+  selectRowValue.value = row;
+};
+
+const handleClose = () => {
+  // 在这里可以清空打开的commonTable的搜索条件
+  search.value.bomMaterialCode = "";
+
+  crudRef.value.clearSelection();
+  toDeleteIds.value = [];
+  selectedRows.value = [];
+  selectRowValue.value = {};
+  isShowTable.value = false;
+
+  console.log(
+    "关闭弹窗",
+    toDeleteIds.value,
+    selectedRows.value,
+    selectRowValue.value
+  );
+};
+
+const onSelected = () => {
+  if (props.multiple) {
+    if (toDeleteIds.value.length < 1) {
+      ElMessage.warning("未选择任何数据");
+      return;
+    }
+    commonTableEmits("selectMultipleSure", toDeleteIds.value);
+  } else {
+    if (props.multipleRow) {
+      console.log(selectedRows);
+      commonTableEmits("selectedSure", selectedRows.value);
+    } else {
+      commonTableEmits("selectedSure", selectRowValue.value);
+    }
+  }
+
+  handleClose();
+};
+
+defineExpose({ startSelect, refreshDictData, mergeOption });
+</script>

+ 92 - 142
src/views/statistic/firstPassYield/index.vue

@@ -6,7 +6,7 @@
           <div class="text">选择统计时间段:</div>
           <div style="display: flex">
             <el-date-picker
-              v-model="value1"
+              v-model="searchTime"
               type="daterange"
               range-separator="-"
               start-placeholder="起始时间"
@@ -35,7 +35,6 @@
             :data="statProductionLineData"
             show-checkbox
             default-expand-all
-            :default-checked-keys="['line']"
             node-key="key"
           />
         </div>
@@ -71,12 +70,15 @@
       <div class="box">
         <div class="boxheader">
           <div>
-            <el-button type="primary" class="btn" @click="getTableDataSearch"
+            <el-button type="primary" class="btn" @click="getTableData"
               >统计查询</el-button
             >
             <el-button class="btn" @click="reset">重置</el-button>
           </div>
-          <el-button class="btn" @click="exportFnc">导出</el-button>
+
+            <el-button class="ml-3" @click="exportData('/api/v1/quality/stat/export')">
+                <template #icon> <i-ep-download /> </template>导出
+            </el-button>
         </div>
         <div class="info">
           <el-table
@@ -100,13 +102,13 @@
               prop="operationName"
               label="工序名称"
             /> -->
-            <el-table-column prop="productLineName" label="车间名称" />
-            <el-table-column prop="productName" label="产品名称" />
-            <el-table-column prop="productCode" label="产品编码" />
-            <el-table-column prop="batchNo" label="产品批次" />
-            <el-table-column prop="goodRate" label="良率" />
-            <el-table-column prop="badRate" label="不良率" />
-            <el-table-column prop="timeStr" label="日期" />
+            <el-table-column prop="workshopName" label="车间名称" />
+            <el-table-column prop="materialName" label="产品名称" />
+            <el-table-column prop="materialCode" label="产品编码" />
+            <el-table-column prop="workOrderCode" label="产品批次" />
+            <el-table-column prop="qualified" label="良率" />
+            <el-table-column prop="noQualified" label="不良率" />
+            <el-table-column prop="updated" label="日期" />
           </el-table>
         </div>
         <div class="footer">
@@ -123,64 +125,35 @@
       </div>
     </div>
   </div>
-  <el-dialog title="选择统计产品" v-model="dialogVisible" width="60%" center>
-    <div>
-      <Search :searchOptions="searchForm" ref="searchRef" />
-    </div>
-    <div>
-      <el-table
-        :data="tableProdtData"
-        row-key="id"
-        border
-        @selection-change="handleSelectionChange"
-      >
-        <el-table-column type="selection" width="55" />
-        <el-table-column prop="productLineName" label="车间名称" />
-        <el-table-column prop="productName" label="产品名称" />
-        <el-table-column prop="productCode" label="产品编码" />
-        <el-table-column prop="batchNo" label="产品批次" />
-        <el-table-column prop="productType" label="产品类型" />
-        <el-table-column prop="timeStr" label="创建日期" />
-      </el-table>
-      <Pagination
-        :total="currentProdtOption.total"
-        :page="currentProdtOption.page"
-        :limit="currentProdtOption.limit"
-        :pageSizes="currentProdtOption.pageSizes"
-        v-model:page="currentProdtOption.page"
-        v-model:limit="currentProdtOption.limit"
-        @pagination="getProdtData"
-      />
-    </div>
-    <div>
-      <el-button type="primary" class="btn" @click="handleConfirm"
-        >确定</el-button
-      >
-      <el-button class="btn" @click="dialogVisible = false">取消</el-button>
-    </div>
-  </el-dialog>
+
+  <CrudTable
+      ref="ctableRef"
+      tableTitle="选择统计产品"
+      :multipleRow="multipleRow"
+      tableType="WORK_ORDER"
+      @selected-sure="handleConfirm"
+  />
 </template>
 
 <script setup>
-import { getData, getStatLevel, getExport } from "@/api/statistic";
+import {getData, getStatLevel, getExport} from "@/api/statistic";
 import { getMockData } from "@/api/statistic/firstPassYieldMockData";
 import Pagination from "@/components/Pagination/index.vue";
 import { downFile } from "@/utils/common";
 import Search from "@/components/Search/index.vue";
-
+import {getWorkOrderInfo, getWorkShop} from "@/api/statistic/firstPassYieldData";
+import {useCrud} from "@/hooks/userCrud";
+const checkList=ref(null);
+const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
+    useCrud({
+        src: "/api/v1/quality/stat",
+    });
+const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
 defineOptions({
   name: "Dashboard",
   inheritAttrs: false,
 });
-const exportFnc = async () => {
-  await getExport({
-    endTime: value1.value ? value1.value[1] : "",
-    startTime: value1.value ? value1.value[0] : "",
-    queryTypes: getValue(treeRef1.value.getCheckedNodes()),
-    queryIndex: getValue(treeRef2.value.getCheckedNodes()),
-    timeType: radio.value,
-  }).then((res) => downFile(res));
-};
+const ctableRef=ref(null);
 const treeRef1 = ref(null);
 const treeRef2 = ref(null);
 const currentOption = ref({
@@ -193,7 +166,6 @@ const currentOption = ref({
 const maxHeight = ref(null);
 const maxWidth = ref(null);
 
-const value1 = ref(null);
 const radio = ref(1);
 const tableData = ref([]);
 
@@ -225,11 +197,10 @@ const getCurrentMonthStartAndEndDates = () => {
 const getValue = (array) => {
   let resarray = [];
   for (let i = 0; i < array.length; i++) {
-    resarray.push(array[i].value);
+    resarray.push(array[i].label);
   }
   return resarray;
 };
-const queryIndexs = ref([]);
 // const getTableData = async () => {
 //   queryIndexs.value = getValue(treeRef1.value.getCheckedNodes());
 //   const { data } = await getData({
@@ -247,45 +218,49 @@ const queryIndexs = ref([]);
 
 // mock数据
 const getTableData = async () => {
-  queryIndexs.value = getValue(treeRef1.value.getCheckedNodes());
-  const { data } = await getMockData({
-    page: currentOption.value.page,
-    limit: currentOption.value.limit,
+    search.value={};
+  const { data } = await getWorkOrderInfo({
+    pageNo: currentOption.value.page,
+    pageSize: currentOption.value.limit,
+    endTime: searchTime.value ? searchTime.value[1] : "",
+    startTime: searchTime.value ? searchTime.value[0] : "",
+    queryTypes: getValue(treeRef1.value.getCheckedNodes()),
+    queryIndex: workOrderCodes.value,
   }); // 使用假数据函数
+    search.value.startTime=searchTime.value ? searchTime.value[0] : "",
+        search.value.endTime=searchTime.value ? searchTime.value[1] : "",
+        search.value.queryTypes=getValue(treeRef1.value.getCheckedNodes()),
+        search.value.queryIndex=workOrderCodes.value,
   tableData.value = data.records;
   currentOption.value.total = data.totalCount;
 };
 // -------
 
-const reset = () => {
-  value1.value = getCurrentMonthStartAndEndDates();
+const reset = () => {searchTime.value = getCurrentMonthStartAndEndDates();
   // treeRef1.value.setCheckedKeys([statProductionLineData[0].key], true, true);
   // treeRef2.value.setCheckedKeys([statProductTypeData[0].key], true, true);
-  radio.value = 1;
   currentOption.value.page = 1;
-  treeData.value = [];
-  selectedRows.value = [];
-  tableData.value = [];
+  workOrderCodes.value = [];
+    treeRef1.value.setCheckedNodes([]);
   getTableData();
 };
 
 // mock数据
 const statProductionLineData = ref([
-  {
-    key: "line",
-    label: "微电子车间",
-    children: [],
-  },
 ]);
 
 const tableProdtData = ref([]);
 const dialogVisible = ref(false);
 const searchRef = ref(null);
+const searchTime =ref(null);
 const openProdtForm = async () => {
-  dialogVisible.value = true;
-  getProdtData();
+  ctableRef.value.startSelect();
+  ctableRef.value?.mergeOption({
+    selection: true,
+    reserveSelection: true,
+  });
 };
-
+const multipleRow = ref(true);
 const getProdtData = async () => {
   const { data } = await getMockData({
     page: currentProdtOption.value.page,
@@ -294,33 +269,7 @@ const getProdtData = async () => {
   tableProdtData.value = data.records;
   currentProdtOption.value.total = data.totalCount;
 };
-const searchForm = [
-  {
-    label: "产品名称",
-    type: "input",
-    key: "prodtName",
-  },
-  {
-    label: "产品编码",
-    type: "input",
-    key: "prodtCode",
-  },
-  {
-    label: "产品类型",
-    type: "select",
-    key: "prodtType",
-    options: [
-      {
-        label: "类型1",
-        value: "1",
-      },
-      {
-        label: "类型2",
-        value: "2",
-      },
-    ],
-  },
-];
+
 
 const currentProdtOption = ref({
   total: 0,
@@ -329,63 +278,48 @@ const currentProdtOption = ref({
   pageSizes: [10, 20, 30, 40, 50, 100],
 });
 // --------------------------------------------
-const statProductTypeData = ref([
-  {
-    key: "id",
-    label: "产品类型",
-    children: [
-      {
-        key: "productType1",
-        label: "类型1",
-      },
-      {
-        key: "productType2",
-        label: "类型2",
-      },
-    ],
-  },
-]);
+
 const selectedRows = ref([]); // 存储选中的行数据
 
-const handleSelectionChange = (rows) => {
-  selectedRows.value = rows; // 更新选中的行数据
-};
 
 const treeData = ref([]); // 存储转换后的 el-tree 数据
-const handleConfirm = () => {
+
+const workOrderCodes = ref([]);
+const handleConfirm = (val) => {
   const map = {};
   const tree = [];
-
-  selectedRows.value.forEach((row) => {
-    const { productName, batchNo } = row;
+    workOrderCodes.value=[];
+  val.forEach((row) => {
+      workOrderCodes.value.push(row.workOrderCode);
+    const { materialName, workOrderCode } = row;
 
     // 如果父级节点不存在,创建父级节点
-    if (!map[productName]) {
+    if (!map[materialName]) {
       const parentNode = {
-        label: productName, // 父级名称
-        key: productName, // 父级唯一标识
+        label: materialName, // 父级名称
+        key: materialName, // 父级唯一标识
         children: [], // 子级数组
       };
-      map[productName] = parentNode;
+      map[materialName] = parentNode;
       tree.push(parentNode);
     }
 
     // 添加子级节点
-    map[productName].children.push({
-      label: batchNo, // 子级名称
-      key: batchNo, // 子级唯一标识
+    map[materialName].children.push({
+      label: workOrderCode, // 子级名称
+      key: workOrderCode, // 子级唯一标识
     });
   });
 
   treeData.value = tree; // 更新 el-tree 数据源
-  dialogVisible.value = false; // 关闭对话框
 };
-
+//列表搜索体哦阿健
+const searchPageForm = ref({});
 const getTableDataSearch = () => {
-  if (treeData.value.length === 0) {
+ /* if (treeData.value.length === 0) {
     ElMessage.warning("请选择产品");
     return;
-  }
+  }*/
   // 提取 treeData 中的 productName 和 batchNo
   const selectedProductMap = {};
   treeData.value.forEach((parent) => {
@@ -412,11 +346,27 @@ const checkedKeys = computed(() => {
   }
   return array;
 });
+const getWorkShopList=()=>{
+    getWorkShop({}).then(
+        (data)=>{
+          statProductionLineData.value=data.data;
 
+        }
+    )
+}
+/*const handleCheckChange=(data, checked, indeterminate)=>{
+    console.log("aaaaa",data); // 选中的节点数据
+    console.log(checked); // 是否选中
+    console.log(indeterminate); // 是否为半选状态
+}*/
 onMounted(async () => {
+
   window.addEventListener("resize", setHeight);
-  value1.value = getCurrentMonthStartAndEndDates();
-  setHeight();
+    searchTime.value = getCurrentMonthStartAndEndDates();
+    search.value.startTime=searchTime.value[0];
+    search.value.endTime=searchTime.value[1];
+    setHeight();
+  await  getWorkShopList();
   // await getStatLevelData();
   getTableData();
 });

+ 1 - 1
src/views/statistic/report/index.vue

@@ -24,7 +24,7 @@
       <template #menu-right="{}">
         <el-button
           class="ml-3"
-          @click="exportData('/api/v1/plan/order/export')"
+          @click="exportData('/api/v1/quality/report/export')"
         >
           <template #icon> <i-ep-download /> </template>导出
         </el-button>

+ 15 - 15
src/views/statistic/report/toPrintTables.vue

@@ -93,8 +93,8 @@ defineExpose({
                   </tr>
                 </thead>
                 <tbody>
-                  <tr v-for="(itemOperation, index) in item.filterDetailList" :key="index">
-                    <td v-for="(item, index) in itemOperation">{{ item }}</td>
+                  <tr v-for="(itemOperation, index) in item.filterDetailList" :key="index" >
+                    <td style="text-align: center" v-for="(item, index) in itemOperation">{{ item }}</td>
 
 
                   </tr>
@@ -125,15 +125,15 @@ defineExpose({
                 <tbody>
 
                   <tr v-for="(item, index) in tableData.salesReportList" :key="index">
-                    <td>{{ item.created }}</td>
-                    <td>{{ item.materialModel }}</td>
-                    <td>{{ item.workOrderCode }}</td>
-                    <td>{{ item.num }}</td>
-                    <td>{{ item.customer }}</td>
-                    <td>{{ item.remark1 }}</td>
-                    <td>{{ item.remark3 }}</td>
-                    <td>{{ item.remark4 }}</td>
-                    <td>{{ item.remark }}</td>
+                    <td style="text-align: center">{{ item.created }}</td>
+                    <td style="text-align: center">{{ item.materialModel }}</td>
+                    <td style="text-align: center">{{ item.workOrderCode }}</td>
+                    <td style="text-align: center">{{ item.num }}</td>
+                    <td style="text-align: center">{{ item.customer }}</td>
+                    <td style="text-align: center">{{ item.remark1 }}</td>
+                    <td style="text-align: center">{{ item.remark3 }}</td>
+                    <td style="text-align: center">{{ item.remark4 }}</td>
+                    <td style="text-align: center">{{ item.remark }}</td>
                   </tr>
                 </tbody>
               </table>
@@ -207,10 +207,10 @@ defineExpose({
               </thead>
               <tbody>
                 <tr v-for="(item, index) in tableData.instockReportList" :key="index">
-                  <td>{{ index+1 }}</td>
-                  <td>{{ item.materialModel }}</td>
-                  <td>{{ item.workOrderCode }}</td>
-                  <td>{{ item.num }}</td>
+                  <td style="text-align: center">{{ index+1 }}</td>
+                  <td style="text-align: center">{{ item.materialModel }}</td>
+                  <td style="text-align: center">{{ item.workOrderCode }}</td>
+                  <td style="text-align: center">{{ item.num }}</td>
                 </tr>
               </tbody>
             </table>

+ 73 - 44
src/views/statistic/statistic/index.vue

@@ -6,7 +6,7 @@
           <div class="text">选择统计时间段:</div>
           <div style="display: flex">
             <el-date-picker
-              v-model="value1"
+              v-model="searTime"
               type="daterange"
               range-separator="-"
               start-placeholder="起始时间"
@@ -41,11 +41,15 @@
         </div>
         <div class="header" style="border-bottom: 0px">
           <div class="text">选择统计指标:</div>
-          <el-radio-group v-model="radio" style="width: 100px;margin-left: 25px">
-            <el-radio size="small" :value="pass">合格率</el-radio>
-            <el-radio size="small" :value="2">一次性送检合格率</el-radio>
-            <el-radio size="small" :value="3">PPM</el-radio>
-          </el-radio-group>
+          <el-tree
+            ref="treeRef2"
+            :data="data1"
+            show-checkbox
+            default-expand-all
+            :default-checked-keys="['合格率']"
+            node-key="key"
+            highlight-current
+          />
         </div>
       </el-scrollbar>
     </div>
@@ -58,7 +62,9 @@
             >
             <el-button class="btn" @click="reset">重置</el-button>
           </div>
-          <el-button class="btn" @click="exportFnc">导出</el-button>
+          <el-button class="ml-3" @click="exportData('/api/v1/quality/stat/quality/export')">
+            <template #icon> <i-ep-download /> </template>导出
+          </el-button>
         </div>
         <div class="info">
           <el-table
@@ -68,23 +74,27 @@
             style="width: calc(100% - 50)"
           >
             <el-table-column
-              v-if="queryIndexs.includes('productLine')"
+              v-if="queryTypes.includes('productLine')"
               prop="productLineName"
               label="产线名称"
             />
             <el-table-column
-              v-if="queryIndexs.includes('prodict')"
-              prop="materialName"
-              label="产品名称"
+                v-if="queryTypes.includes('workSection')"
+                prop="workSection"
+                label="工段名称"
             />
             <el-table-column
-              v-if="queryIndexs.includes('operation')"
+              v-if="queryTypes.includes('operation')"
               prop="operationName"
               label="工序名称"
             />
-            <el-table-column prop="goodRate" label="良率" />
-            <el-table-column prop="badRate" label="不良率" />
-            <el-table-column prop="timeStr" label="日期" />
+            <el-table-column prop="materialName" label="产品名称" />
+            <el-table-column prop="materialCode" label="产品编号" />
+            <el-table-column  prop="produceNum" label="生产数量"  />
+            <el-table-column v-if="queryIndexs.includes('pass')" prop="qualified" label="合格率"  />
+            <el-table-column v-if="queryIndexs.includes('oneTimePassRate')" prop="oneTimePassRate" label="一次性合格率" />
+            <el-table-column v-if="queryIndexs.includes('PPM')" prop="ppm" label="PPM" />
+
           </el-table>
         </div>
         <div class="footer">
@@ -107,14 +117,21 @@
 import { getData, getStatLevel, getExport } from "@/api/statistic";
 import Pagination from "@/components/Pagination/index.vue";
 import { downFile } from "@/utils/common";
+import {getWorkInfoRate, getWorkOrderInfo} from "@/api/statistic/firstPassYieldData";
+import {useCrud} from "@/hooks/userCrud";
 defineOptions({
   name: "Dashboard",
   inheritAttrs: false,
 });
+const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
+    useCrud({
+        src: "/api/v1/quality/stat",
+    });
+const { checkBtnPerm, downloadTemplate, exportData } = Utils;
 const exportFnc = async () => {
   await getExport({
-    endTime: value1.value ? value1.value[1] : "",
-    startTime: value1.value ? value1.value[0] : "",
+    endTime: searTime.value ? searTime.value[1] : "",
+    startTime: searTime.value ? searTime.value[0] : "",
     queryTypes: getValue(treeRef1.value.getCheckedNodes()),
     queryIndex: getValue(treeRef2.value.getCheckedNodes()),
     timeType: radio.value,
@@ -128,28 +145,12 @@ const currentOption = ref({
   limit: 10,
   pageSizes: [10, 20],
 });
-const data1 = [
-  {
-    value: "pass",
-    key: "合格率",
-    label: "合格率",
-  },
-  {
-    value: "oneTimePassRate",
-    key: "一次性送检合格率",
-    label: "一次性送检合格率",
-  },
-  {
-    value: "PPM",
-    key: "PPM",
-    label: "PPM",
-  },
-];
+
 const maxHeight = ref(null);
 const maxWidth = ref(null);
 
-const value1 = ref(null);
-const radio = ref(1);
+const searTime = ref(null);
+const radio = ref('1');
 const tableData = ref([]);
 
 const setHeight = () => {
@@ -185,28 +186,52 @@ const getValue = (array) => {
   return resarray;
 };
 const queryIndexs = ref([]);
+const queryTypes=ref([]);
 const getTableData = async () => {
-  queryIndexs.value = getValue(treeRef1.value.getCheckedNodes());
-  const { data } = await getData({
-    endTime: value1.value ? value1.value[1] : "",
-    startTime: value1.value ? value1.value[0] : "",
+  queryTypes.value = getValue(treeRef1.value.getCheckedNodes());
+  queryIndexs.value=getValue(treeRef2.value.getCheckedNodes());
+  const { data } = await getWorkInfoRate({
+    endTime: searTime.value ? searTime.value[1] : "",
+    startTime: searTime.value ? searTime.value[0] : "",
     pageNo: currentOption.value.page,
     pageSize: currentOption.value.limit,
     queryTypes: getValue(treeRef1.value.getCheckedNodes()),
     queryIndex: getValue(treeRef2.value.getCheckedNodes()),
-    timeType: radio.value,
   });
+    search.value.startTime=searTime.value[0];
+    search.value.endTime=searTime.value[1];
+    search.value.queryTypes=getValue(treeRef1.value.getCheckedNodes());
+    search.value.queryIndex=getValue(treeRef2.value.getCheckedNodes());
   tableData.value = data.records;
   currentOption.value.total = data.totalCount;
 };
+
 const reset = () => {
-  value1.value = getCurrentMonthStartAndEndDates();
+  console.log();
+  searTime.value = getCurrentMonthStartAndEndDates();
   treeRef1.value.setCheckedKeys(checkedKeys.value, true, true);
   treeRef2.value.setCheckedKeys([data1[0].key], true, true);
-  radio.value = 1;
+  radio.value = '1';
   currentOption.value.page = 1;
   getTableData();
 };
+const data1 = [
+  {
+    value: "pass",
+    key: "合格率",
+    label: "合格率",
+  },
+  {
+    value: "oneTimePassRate",
+    key: "一次性送检合格率",
+    label: "一次性送检合格率",
+  },
+  {
+    value: "PPM",
+    key: "PPM",
+    label: "PPM",
+  },
+];
 const statLevelData = ref([]);
 const getStatLevelData = async () => {
   const { data } = await getStatLevel();
@@ -225,9 +250,13 @@ const checkedKeys = computed(() => {
 
 onMounted(async () => {
   window.addEventListener("resize", setHeight);
-  value1.value = getCurrentMonthStartAndEndDates();
+  searTime.value = getCurrentMonthStartAndEndDates();
   setHeight();
   await getStatLevelData();
+    search.value.startTime=searTime.value[0];
+    search.value.endTime=searTime.value[1];
+    search.value.queryTypes=getValue(treeRef1.value.getCheckedNodes());
+    search.value.queryIndex=getValue(treeRef2.value.getCheckedNodes());
   getTableData();
 });
 </script>