yaowanxin
2 天以前 093615ab71eebddeea28a74a6c21898fc929450f
判断检测项,调整请求
已修改3个文件
31 ■■■■■ 文件已修改
src/utils/connect.js 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/resourceDemand/device/component/acquisitionConfig.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionTask/inspection.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/connect.js
@@ -4,24 +4,12 @@
    let reader = null;
    let accumulatedData = ""; // 移到全局,便于关闭时重置
    let weightList = []; // 用于存储重量值的列表
    async function sendWeightsToBackend(weights) {
      try {
        // 使用 await 等待 request 函数返回结果
        const response = await request({
    export function sendWeightsToBackend(weights) {
      return request({
          url: "/weight/handleWeights",
          method: "POST",
          data: weights, // 通常 request 函数使用 data 字段传递数据
        data: weights,
        });
        // 根据 request 函数的实现判断响应是否成功
        if (response.code !== 200) { // 假设 response 有 code 字段,200 表示成功
          throw new Error(`Backend response error: ${response.message}`);
        }
        return response.data; // 假设响应数据在 data 字段中
      } catch (error) {
        console.error('发送重量数据到后端失败:', error);
        throw error;
      }
    }
    async function connect() {
@@ -108,7 +96,7 @@
        }
        */
      }
    }
    // 新增提取重量数值的方法
    function extractWeightValue(message) {
      // 匹配数值部分,可处理正负号
src/views/CNAS/resourceDemand/device/component/acquisitionConfig.vue
@@ -268,8 +268,8 @@
        { label: "db", value: ".db" },
        { label: "mdb", value: ".mdb" },
        { label: "word", value: ".docx" },
        { label: "excel", value: ".xlsx" },
        { label: "excel", value: ".xls" },
        { label: "excelxlsx", value: ".xlsx" },
        { label: "excelxls", value: ".xls" },
        { label: "txt", value: ".txt" },
        { label: "mysql", value: ".mysql" },
        { label: "mqtt", value: ".mqtt" },
src/views/business/inspectionTask/inspection.vue
@@ -1152,6 +1152,12 @@
  getDataAcquisitionDevice() {
      (async () => {
        try {
          // 检查页面中检测项是否包含密度
          const hasDensityItem = this.currentSample.insProduct.some(item => {
            // 假设密度相关的检测项名称包含 "密度" 关键字,可按需修改
            return item.inspectionItem && item.inspectionItem.includes('密度');
          });
          if (hasDensityItem) {
          // 检查是否支持 Web Serial API
          if ('serial' in navigator) {
            // 请求可用串口
@@ -1164,6 +1170,7 @@
          } else {
            console.log('当前浏览器不支持 Web Serial API');
          }
          }
        } catch (error) {
          console.error('检测串口时出错:', error);
        }