wangyi
2026-03-11 7f93c91382c392e836312c3af982ca3fa9fa1025
Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-VUEUI
6个文件已修改
120 ■■■■■ 已修改文件
.env.development 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.env.production 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/permission.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/healthCheck.js 103 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/component/printList/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warehouse/barcodeMaster/Gy_BarCodeBillList.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
.env.development
@@ -10,8 +10,8 @@
# VUE_APP_BASE_API = 'http://220.189.218.155:9010/API/'
VUE_APP_BASE_API = 'http://localhost:8082/LuBaoAPI/'
#锦隆
# # VUE_APP_BASE_API_INNER = 'http://192.168.1.11/API/'
# # VUE_APP_BASE_API = http://61.174.29.234:8880/API/
VUE_APP_BASE_API_INNER = http://192.168.1.11/API/
VUE_APP_BASE_API = http://61.174.29.234:8880/API/
# 宁波 四维尔
# VUE_APP_BASE_API_INNER = http://192.168.0.236:9010/API/
# VUE_APP_BASE_API = http://220.189.218.155:9010/API/
.env.production
@@ -5,11 +5,11 @@
ENV = 'production'
# 宁波 四维尔
VUE_APP_BASE_API_INNER = http://192.168.0.236:9010/API/
VUE_APP_BASE_API = http://220.189.218.155:9010/API/
# VUE_APP_BASE_API_INNER = http://192.168.0.236:9010/API/
# VUE_APP_BASE_API = http://220.189.218.155:9010/API/
# 余姚 锦隆 智能家居
# VUE_APP_BASE_API_INNER = http://192.168.1.11/API/
# VUE_APP_BASE_API = http://61.174.29.234:8880/API/
VUE_APP_BASE_API_INNER = http://192.168.1.11/API/
VUE_APP_BASE_API = http://61.174.29.234:8880/API/
# 智云迈思L-MOM管理系统/生产环境
# VUE_APP_BASE_API = http://47.96.97.237/API/
#杜贺
src/permission.js
@@ -22,6 +22,7 @@
  "/gyEmployee",
  "/GyCustomer",
  "/gyMaterial",
  "/hBarPlanPrintWeb",
  "/FbStepFoldinBillList",
  "/FbStepFoldOutBillList",
  "/warehouse/barcodeMaster/Gy_BarCodeBill_JinLong",
src/utils/healthCheck.js
@@ -13,35 +13,75 @@
];
/**
 * 检测单个服务健康状态
 * 带超时控制的 fetch 请求封装
 * @param {string} url 请求地址
 * @param {Object} options fetch 配置
 * @param {number} timeout 超时时间(毫秒),默认 3000ms
 * @returns {Promise<Response>} 请求响应
 */
const fetchWithTimeout = async (url, options = {}, timeout = 3000) => {
    // 1. 创建中止控制器,用于超时取消请求
    const controller = new AbortController();
    const signal = controller.signal;
    // 2. 超时定时器:到时间后中止请求并抛出错误
    const timeoutTimer = setTimeout(() => {
        controller.abort();
        throw new Error(`请求超时(${timeout}ms)`);
    }, timeout);
    try {
        // 3. 绑定中止信号到 fetch 请求
        const response = await fetch(url, {
            ...options,
            signal, // 关键:关联中止控制器
        });
        clearTimeout(timeoutTimer); // 请求成功,清除超时定时器
        return response;
    } catch (error) {
        clearTimeout(timeoutTimer); // 出错/超时,清除定时器
        // 区分中止错误(超时)和其他错误
        if (error.name === 'AbortError') {
            throw new Error(`请求超时:${url} 超过 ${timeout}ms 未响应`);
        }
        throw error; // 抛出其他错误(如网络错误)
    }
};
/**
 * 检测单个服务健康状态(新增超时控制)
 * @param {Object} service - 服务配置(baseUrl + healthPath)
 * @returns {Promise<String|null>} 可用的 baseUrl,失败返回 null
 */
export const checkServiceHealth = async (service) => {
    const { baseUrl, healthPath } = service;
    if (!baseUrl) return null;
    return new Promise(async (resolve, reject) => {
        try {
            // 健康检查请求(超时 3 秒,不携带 Token,避免未登录拦截)
            const response = await fetch(`${baseUrl}${healthPath}`, {
    try {
        // 健康检查请求(使用封装的带超时的 fetch,3秒超时)
        const response = await fetchWithTimeout(
            `${baseUrl}${healthPath}`,
            {
                method: "GET",
                timeout: 3000,
                headers: {
                    "Content-Type": "application/json",
                },
            });
            if (response.ok) {
                console.log(`服务 ${service.name} 健康,地址:${baseUrl}`);
                resolve(baseUrl)
                // return baseUrl;
            }
        } catch (error) {
            console.error(`服务 ${service.name} 连接失败:`, error.message);
            resolve(null)
            // return null;
        }
    })
            },
            3000 // 明确配置 3 秒超时
        );
        if (response.ok) {
            console.log(`服务 ${service.name} 健康,地址:${baseUrl}`);
            return baseUrl;
        } else {
            // 响应状态码非 2xx,视为服务不可用
            console.warn(`服务 ${service.name} 响应异常,状态码:${response.status}`);
            return null;
        }
    } catch (error) {
        console.error(`服务 ${service.name} 连接失败:`, error.message);
        return null;
    }
};
/**
@@ -50,17 +90,22 @@
 */
export const findAvailableService = async () => {
    // 并行检测所有服务(提高效率)
    const healthCheckPromises = serviceList.map((item) => {
        return checkServiceHealth(item)
    });
    const healthResult = await Promise.any(healthCheckPromises); // 检测到健康的链接就立刻返回
    // 筛选可用的 baseUrl
    const availableBaseUrl = healthResult
    try {
        const healthCheckPromises = serviceList.map((item) => {
            return checkServiceHealth(item);
        });
        const healthResult = await Promise.all(healthCheckPromises);
        // 筛选可用的 baseUrl
        console.log("健康检查结果:", healthResult);
        const availableBaseUrl = healthResult.filter((item) => item != null)[0];
    if (availableBaseUrl) {
        return availableBaseUrl;
    } else {
        // 所有服务均不可用,抛出异常(后续在初始化时捕获)
        throw new Error("所有服务健康检查失败,请检查服务状态或网络配置");
        if (availableBaseUrl) {
            return availableBaseUrl;
        } else {
            // 所有服务均不可用,抛出异常
            throw new Error("所有服务健康检查失败,请检查服务状态或网络配置");
        }
    } catch (err) {
        throw err;
    }
};
src/views/component/printList/index.vue
@@ -2,7 +2,7 @@
    <div style="margin-top: -40px;">
        <el-form ref="formData" :model="formData" label-width="100px">
            <div style="padding: 10px; ">
                <el-button type="primary" size="small" @click="printClick">报表打印</el-button>
                <el-button type="primary" size="small" @click="printClick" v-if=false>报表打印</el-button>
                <el-button type="primary" size="small" @click="printClickWeb">报表打印(网页)</el-button>
            </div>
            <el-table v-loading="loading" :data="printdata" ref="printTable" max-height="540"
src/views/warehouse/barcodeMaster/Gy_BarCodeBillList.vue
@@ -180,7 +180,7 @@
      <pagination v-show="total > 0" :total="total" :page.sync="page" :limit.sync="pageSize" @pagination="handleQuery" />
      <!-- 列设置 -->
      <el-dialog title="隐藏列设置" :visible.sync="openRowHide" width="816px" append-to-body>
        <RowSettings :colName="btResList" HModName="Kf_POStockInBillList" @rowEditClose="rowSetClose"
        <RowSettings :colName="btResList" HModName="Gy_BarCodeBillList" @rowEditClose="rowSetClose"
          v-if="rowHideShow" />
      </el-dialog>
      <!-- 打印 -->