| | |
| | | <script setup> |
| | | import { ref, onMounted, nextTick, reactive, computed } from "vue"; |
| | | import { userLoginFacotryList } from "@/api/login"; |
| | | import { getProductWorkOrderById } from "@/api/productionManagement/productionReporting"; |
| | | import DownloadProgressMask from "@/components/DownloadProgressMask.vue"; |
| | | import modal from "@/plugins/modal"; |
| | | import useUserStore from "@/store/modules/user"; |
| | |
| | | // 工艺设计功能数据 |
| | | const designItems = reactive([ |
| | | { |
| | | icon: "/static/images/icon/xiaoshoubaojia.svg", |
| | | icon: "/static/images/icon/jichucanshu.svg", |
| | | label: "基础参数", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/xiaoshoubaojia.svg", |
| | | icon: "/static/images/icon/gongxuguanli.svg", |
| | | label: "工序管理", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/xiaoshoubaojia.svg", |
| | | icon: "/static/images/icon/bom.svg", |
| | | label: "BOM", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/xiaoshoubaojia.svg", |
| | | icon: "/static/images/icon/gongyiluxian.svg", |
| | | label: "工艺路线", |
| | | }, |
| | | ]); |
| | |
| | | // 档案管理功能数据 |
| | | const archiveManagementItems = reactive([ |
| | | { |
| | | icon: "/static/images/icon/gongyingshangdangan.svg", |
| | | icon: "/static/images/icon/jieyuedengji.svg", |
| | | label: "借阅登记", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/hetongguanli.svg", |
| | | icon: "/static/images/icon/guihuandengji.svg", |
| | | label: "归还登记", |
| | | }, |
| | | ]); |
| | |
| | | // 仓储物流功能数据 |
| | | const warehouseLogisticsItems = reactive([ |
| | | { |
| | | icon: "/static/images/icon/xiaoshoutaizhang.svg", |
| | | icon: "/static/images/icon/kucunguanli.svg", |
| | | label: "库存管理", |
| | | }, |
| | | ]); |
| | |
| | | // 生产管控功能数据 |
| | | const productionItems = reactive([ |
| | | { |
| | | icon: "/static/images/icon/shengchandingdan@2x.svg", |
| | | label: "生产订单", |
| | | }, |
| | | // { |
| | | // icon: "/static/images/icon/shengchanpaigong@2x.svg", |
| | | // label: "生产派工", |
| | | // }, |
| | | // { |
| | | // icon: "/static/images/icon/shengchanpaichan@2x.svg", |
| | | // label: "工序排产", |
| | | // }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "主生产计划", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "生产订单", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "生产追溯", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "工序生产实况", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "生产排产", |
| | | }, |
| | | |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "生产报工", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "生产工单", |
| | | label: "报工台账", |
| | | }, |
| | | // { |
| | | // icon: "/static/images/icon/shengchanhesuan@2x.svg", |
| | | // label: "生产核算", |
| | | // }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "生产核算", |
| | | }, |
| | | |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong.svg", |
| | | label: "工序实况", |
| | | }, |
| | | ]); |
| | | |
| | | // 设备管理功能数据 |
| | |
| | | url: "/pages/productionManagement/productionDispatching/index", |
| | | }); |
| | | break; |
| | | case "工序排产": |
| | | case "工艺路线": |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/processScheduling/index", |
| | | url: "/pages/productionManagement/processRoute/index", |
| | | }); |
| | | break; |
| | | case "生产工单": |
| | |
| | | url: "/pages/productionManagement/mainProductionPlan/index", |
| | | }); |
| | | break; |
| | | case "生产排产": |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/productionScheduling/index", |
| | | }); |
| | | break; |
| | | case "生产报工": |
| | | getcode(); |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/productionReport/workOrderList", |
| | | }); |
| | | break; |
| | | case "报工台账": |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/productionReporting/ledger", |
| | | }); |
| | | break; |
| | | case "生产核算": |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/productionAccounting/index", |
| | | }); |
| | | break; |
| | | case "生产追溯": |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/productionTraceability/index", |
| | | }); |
| | | break; |
| | | case "工序生产实况": |
| | | uni.navigateTo({ |
| | | url: "/pages/productionManagement/processStatistics/index", |
| | | }); |
| | | break; |
| | | case "设备台账": |
| | |
| | | factoryList.value = []; |
| | | }); |
| | | } |
| | | const getcode = () => { |
| | | uni.scanCode({ |
| | | success: async res => { |
| | | // 解析二维码内容 |
| | | const scanResult = res.result; |
| | | let orderRow = ""; |
| | | |
| | | // 判断扫描结果是否为纯数字(id) |
| | | const isNumericId = /^\d+$/.test(scanResult.trim()); |
| | | |
| | | if (isNumericId) { |
| | | // 如果是纯数字,根据 id 获取工单数据 |
| | | const workOrderId = scanResult.trim(); |
| | | modal.loading("正在获取工单信息..."); |
| | | try { |
| | | const workRes = await getProductWorkOrderById({ id: workOrderId }); |
| | | modal.closeLoading(); |
| | | |
| | | console.log("工单查询结果:", workRes); |
| | | |
| | | if (workRes.code === 200 && workRes.data) { |
| | | // 新接口返回的是单个对象,不是数组 |
| | | const workData = workRes.data; |
| | | console.log("工单数据:", workData); |
| | | |
| | | orderRow = JSON.stringify(workData); |
| | | |
| | | console.log("构造的orderRow:", orderRow); |
| | | } else { |
| | | modal.msgError("未找到对应的工单信息"); |
| | | return; |
| | | } |
| | | } catch (error) { |
| | | modal.closeLoading(); |
| | | console.error("获取工单信息失败:", error); |
| | | modal.msgError("获取工单信息失败: " + (error.message || "未知错误")); |
| | | return; |
| | | } |
| | | } else { |
| | | // 如果不是纯数字,尝试从扫码结果中提取orderRow参数 |
| | | try { |
| | | // 处理混合格式: http://...?orderRow={...} |
| | | const orderRowStart = scanResult.indexOf("orderRow={"); |
| | | if (orderRowStart !== -1) { |
| | | // 提取从orderRow={开始的JSON内容 |
| | | const jsonPart = scanResult.substring(orderRowStart + 9); // 9是"orderRow=".length |
| | | orderRow = jsonPart; |
| | | } else { |
| | | // 如果直接是JSON字符串,尝试解析 |
| | | orderRow = scanResult; |
| | | } |
| | | } catch (e) { |
| | | console.error(e, "解析失败====????====="); |
| | | orderRow = ""; |
| | | } |
| | | |
| | | // 验证是否为有效的JSON |
| | | try { |
| | | JSON.parse(orderRow); |
| | | } catch (error) { |
| | | modal.msgError("订单解析失败,请检查二维码格式"); |
| | | return; |
| | | } |
| | | } |
| | | // 扫码成功后跳转到生产报工页面,并传递orderRow参数 |
| | | uni.navigateTo({ |
| | | url: `/pages/productionManagement/productionReport/index?orderRow=${orderRow}`, |
| | | }); |
| | | }, |
| | | fail: err => { |
| | | uni.showToast({ |
| | | title: "扫码失败", |
| | | icon: "none", |
| | | }); |
| | | }, |
| | | }); |
| | | }; |
| | | const changeFactory = async arr => { |
| | | show.value = false; |
| | | const factoryId = factoryListTem.value[arr.indexs[0]].deptId; |