Bläddra i källkod

Merge branch 'master' of http://maven.jgiot.com:7012/jiaxiaoqiang/qingban-SPC

lupeng 1 månad sedan
förälder
incheckning
0f1692d903

+ 15 - 0
src/hooks/userCrud.ts

@@ -394,6 +394,21 @@ export const useCrud = (config?: UseCrudConfig) => {
       });
       Utils.downloadFile(response);
     },
+
+    /**
+     * 根据搜索项导出数据
+     */
+    downloadSPCTemplate: async (urlStr: string, filePath: string) => {
+      handleSearchData();
+      const response = await request({
+        url: urlStr,
+        method: "post",
+        data: search.value,
+        params: { filePath: filePath },
+        responseType: "arraybuffer",
+      });
+      Utils.downloadFile(response);
+    },
   };
 
   return {

+ 3 - 3
src/views/analysis/process/CList.vue

@@ -35,7 +35,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/C控制图数据导入模版.xlsx'
                   )
@@ -130,7 +130,7 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
 // 定义 props
 const props = defineProps({
@@ -961,7 +961,7 @@ onBeforeUnmount(() => {
 }
 .blue-underline {
   text-decoration: none;
-  color: black;
+  color: #008cff;
 }
 
 .blue-underline:hover {

+ 3 - 3
src/views/analysis/process/EWMAList.vue

@@ -35,7 +35,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/EWMA控制图数据导入模版.xlsx'
                   )
@@ -130,7 +130,7 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
 // 定义 props
 const props = defineProps({
@@ -961,7 +961,7 @@ onBeforeUnmount(() => {
 }
 .blue-underline {
   text-decoration: none;
-  color: black;
+  color: #008cff;
 }
 
 .blue-underline:hover {

+ 3 - 3
src/views/analysis/process/I-MRList.vue

@@ -35,7 +35,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/I-MR控制图数据导入模版.xlsx'
                   )
@@ -130,7 +130,7 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
 // 定义 props
 const props = defineProps({
@@ -961,7 +961,7 @@ onBeforeUnmount(() => {
 }
 .blue-underline {
   text-decoration: none;
-  color: black;
+  color: #008cff;
 }
 
 .blue-underline:hover {

+ 3 - 3
src/views/analysis/process/NPList.vue

@@ -35,7 +35,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/NP控制图数据导入模版.xlsx'
                   )
@@ -130,7 +130,7 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
 // 定义 props
 const props = defineProps({
@@ -961,7 +961,7 @@ onBeforeUnmount(() => {
 }
 .blue-underline {
   text-decoration: none;
-  color: black;
+  color: #008cff;
 }
 
 .blue-underline:hover {

+ 3 - 3
src/views/analysis/process/PList.vue

@@ -35,7 +35,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/P控制图数据导入模版.xlsx'
                   )
@@ -130,7 +130,7 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
 // 定义 props
 const props = defineProps({
@@ -961,7 +961,7 @@ onBeforeUnmount(() => {
 }
 .blue-underline {
   text-decoration: none;
-  color: black;
+  color: #008cff;
 }
 
 .blue-underline:hover {

+ 3 - 3
src/views/analysis/process/UList.vue

@@ -35,7 +35,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/U控制图数据导入模版.xlsx'
                   )
@@ -130,7 +130,7 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
 // 定义 props
 const props = defineProps({
@@ -961,7 +961,7 @@ onBeforeUnmount(() => {
 }
 .blue-underline {
   text-decoration: none;
-  color: black;
+  color: #008cff;
 }
 
 .blue-underline:hover {

+ 43 - 15
src/views/analysis/process/Xbar-RList.vue

@@ -37,7 +37,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/XBarR控制图数据导入模版.xlsx'
                   )
@@ -200,17 +200,19 @@
                   ><span>{{ row.measure }}</span>
                 </template>
               </el-table-column>
-              <el-table-column align="center" width="240" prop="" label="操作">
+              <el-table-column align="center" width="255" prop="" label="操作">
                 <template #default="{ row }">
                   <el-button
                     v-if="row.source === '自动'"
-                    type="primary"
+                    :type="loadingRows[row.id] ? 'info' : 'primary'"
                     size="small"
-                    class="btn"
+                    :loading="loadingRows[row.id]"
                     @click="dataAcquisition(row)"
+                    :disabled="loadingRows[row.id]"
                     style="height: 25px"
-                    >采集数据</el-button
                   >
+                    {{ loadingRows[row.id] ? "数据采集中..." : "采集数据" }}
+                  </el-button>
                   <el-button
                     type="primary"
                     size="small"
@@ -350,18 +352,36 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
-const emit = defineEmits(["tableData"]);
+const { downloadSPCTemplate } = Utils;
+const emit = defineEmits([
+  "tableData",
+  "update:addStatus",
+  "update:editStatus",
+]);
+
+// 在你的组件 setup 中
+const loadingRows = ref({});
 
 const dataAcquisition = async (row) => {
-  const { data } = await collectData({
-    qualitySpcRecordId: row.id,
-    model: row.model,
-    batchNo: row.batchNo,
-    operation: lableValue.value,
-  });
-  emit("tableData", data);
-  getTableData();
+  loadingRows.value = { ...loadingRows.value, [row.id]: true };
+  try {
+    // 这里替换为你的实际请求
+    const { code } = await collectData({
+      qualitySpcRecordId: row.id,
+      model: row.model,
+      batchNo: row.batchNo,
+      operation: lableValue.value,
+    });
+    if (200 == code) {
+      ElMessage.success("数据采集成功!");
+      getTableData();
+    }
+  } catch (error) {
+    console.error("数据采集失败:", error);
+    // 可以在这里添加错误处理,比如显示错误消息
+  } finally {
+    loadingRows.value = { ...loadingRows.value, [row.id]: false };
+  }
 };
 
 const compute = async () => {
@@ -449,10 +469,13 @@ const changeEditstatus = () => {
 const changeaddstatus = () => {
   addStatus.value = !addStatus.value;
   editStatus.value = false;
+  emit("update:addStatus", addStatus.value);
 };
 const canceleOp = () => {
   addStatus.value = false;
   editStatus.value = false;
+  emit("update:addStatus", addStatus.value);
+  emit("update:editStatus", editStatus.value);
   reset();
 };
 
@@ -607,6 +630,8 @@ const updataItem = (row) => {
   editStatus.value = true;
   addData.value = row;
   addStatus.value = true;
+  emit("update:addStatus", addStatus.value);
+  emit("update:editStatus", editStatus.value);
 };
 const taskOption = ref([]);
 const value = ref(opOptions.value[0].remark);
@@ -656,6 +681,7 @@ const deleteSubmit = async (id) => {
   }
 };
 const updateSubmit = async () => {
+  addData.value.abnormal = null;
   const { data, code } = await updateData({
     ...addData.value,
   });
@@ -668,6 +694,8 @@ const updateSubmit = async () => {
 const reset = () => {
   addStatus.value = false;
   editStatus.value = false;
+  emit("update:addStatus", addStatus.value);
+  emit("update:editStatus", editStatus.value);
   addData.value = { ...resItem };
   searchRef.value.searchForm = {};
   currentOption.value = {

+ 15 - 3
src/views/analysis/process/Xbar-SList.vue

@@ -37,7 +37,7 @@
                 size="small"
                 class="btn"
                 @click="
-                  exportData(
+                  downloadSPCTemplate(
                     '/api/v1/spc/downloadTemplate',
                     '/spc/template/XBarS控制图数据导入模版.xlsx'
                   )
@@ -331,9 +331,13 @@ import { useCrud } from "@/hooks/userCrud";
 const { Utils } = useCrud({
   src: "/api/v1/spc/pDownloadTemplate",
 });
-const { exportData } = Utils;
+const { downloadSPCTemplate } = Utils;
 
-const emit = defineEmits(["tableData"]);
+const emit = defineEmits([
+  "tableData",
+  "update:addStatus",
+  "update:editStatus",
+]);
 const compute = async () => {
   // 存储提取的 accuracys 数据
   const accuracysList = ref([]);
@@ -418,10 +422,13 @@ const changeEditstatus = () => {
 const changeaddstatus = () => {
   addStatus.value = !addStatus.value;
   editStatus.value = false;
+  emit("update:addStatus", addStatus.value);
 };
 const canceleOp = () => {
   addStatus.value = false;
   editStatus.value = false;
+  emit("update:addStatus", addStatus.value);
+  emit("update:editStatus", editStatus.value);
   reset();
 };
 const disabled = ref(false);
@@ -571,6 +578,8 @@ const updataItem = (row) => {
   editStatus.value = true;
   addData.value = row;
   addStatus.value = true;
+  emit("update:addStatus", addStatus.value);
+  emit("update:editStatus", editStatus.value);
 };
 const taskOption = ref([]);
 const value = ref(opOptions.value[0].remark);
@@ -620,6 +629,7 @@ const deleteSubmit = async (id) => {
   }
 };
 const updateSubmit = async () => {
+  addData.value.abnormal = null;
   const { data, code } = await updateData({
     ...addData.value,
   });
@@ -632,6 +642,8 @@ const updateSubmit = async () => {
 const reset = () => {
   addStatus.value = false;
   editStatus.value = false;
+  emit("update:addStatus", addStatus.value);
+  emit("update:editStatus", editStatus.value);
   addData.value = { ...resItem };
   searchRef.value.searchForm = {};
   currentOption.value = {

+ 5 - 1
src/views/analysis/process/index.vue

@@ -69,12 +69,16 @@
             <XbarRList
               ref="xbarrListRef"
               @table-data="handleDataFromChildXbarR"
+              v-model:addStatus="addStatus"
+              v-model:editStatus="editStatus"
             />
           </div>
           <div class="info" v-if="value2 === 'Xbar-S'">
             <XbarSList
               ref="xbarsListRef"
               @table-data="handleDataFromChildXbarS"
+              v-model:addStatus="addStatus"
+              v-model:editStatus="editStatus"
             />
           </div>
           <div class="info" v-if="value2 === 'P'">
@@ -120,7 +124,7 @@
             />
           </div>
         </div>
-        <div class="box" v-show="!addStatus">
+        <div class="box" v-show="!addStatus && !editStatus">
           <div class="info" v-if="value2 === 'Xbar-R'">
             <XbarR ref="xbarRRef" :process="showLable" />
           </div>

+ 2 - 2
src/views/analysis/spc/index.vue

@@ -58,14 +58,14 @@
               class="btn"
               style="height: 25px"
               @click="toEdit(row)"
-              link
+              size="small"
               >编辑</el-button
             >
             <el-button
               type="info"
               class="btn"
               style="height: 25px"
-              link
+              size="small"
               @click="toDelete(row.id)"
               >删除</el-button
             >

+ 3 - 0
src/views/analysis/target/index/index.vue

@@ -266,6 +266,7 @@
                       class="btn"
                       @click="computeCPK(row.id)"
                       style="height: 25px"
+                      size="small"
                       >计算Cpk</el-button
                     >
                     <el-button
@@ -273,6 +274,7 @@
                       class="btn"
                       @click="updataItem(row.Index)"
                       style="height: 25px"
+                      size="small"
                       >修改</el-button
                     >
                     <el-button
@@ -280,6 +282,7 @@
                       class="btn"
                       style="height: 25px"
                       @click="deleteSubmit(row.id)"
+                      size="small"
                       >删除</el-button
                     >
                   </template>