zhangwencui
6 天以前 ba448d252ae2f7d904b47869b3d7203c4a81ac6d
增加扫码报工功能测试修改
已修改3个文件
62 ■■■■ 文件已修改
src/api/productionManagement/productionReporting.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/productionManagement/productionReport/index.vue 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/productionManagement/productionReporting.js
@@ -33,3 +33,12 @@
    data: query,
  });
}
// 新增产品主表
export function addProductMain(data) {
  return request({
    url: "/productionProductMain/addProductMain",
    method: "post",
    data: data,
  });
}
src/pages/index.vue
@@ -533,19 +533,18 @@
        let orderRow = "";
        // 尝试从扫码结果中提取orderRow参数
        // 假设二维码内容是JSON格式或URL参数格式
        try {
          // 检查是否是JSON格式
          const parsedData = JSON.parse(scanResult);
          if (parsedData.orderRow) {
            orderRow = parsedData.orderRow;
          }
          // 处理混合格式: http://...?orderRow={...}
          const orderRowStart = scanResult.indexOf("orderRow={");
          // 提取从orderRow={开始的JSON内容
          const jsonPart = scanResult.substring(orderRowStart + 9); // 9是"orderRow=".length
          // 尝试直接使用这个JSON部分
          orderRow = jsonPart;
        } catch (e) {
          // 检查是否是URL参数格式,如 orderRow=12345
          const params = new URLSearchParams(scanResult);
          orderRow = params.get("orderRow") || "";
          console.error(e, "解析失败====????=====");
          orderRow = "";
        }
        console.log(orderRow, "orderRow======@@@@@@@@");
        // 扫码成功后跳转到生产报工页面,并传递orderRow参数
        uni.navigateTo({
          url: `/pages/productionManagement/productionReport/index?orderRow=${orderRow}`,
src/pages/productionManagement/productionReport/index.vue
@@ -53,6 +53,7 @@
<script setup>
  import { ref, onMounted } from "vue";
  import { onLoad } from "@dcloudio/uni-app";
  import FooterButtons from "@/components/FooterButtons.vue";
  const showToast = message => {
@@ -61,10 +62,7 @@
      icon: "none",
    });
  };
  import { formatDateToYMD } from "@/utils/ruoyi";
  import { userListNoPageByTenantId } from "@/api/system/user";
  import { productionReport } from "@/api/productionManagement/productionReporting";
  import { addProductMain } from "@/api/productionManagement/productionReporting";
  import { getInfo } from "@/api/login";
  // 表单引用
@@ -105,7 +103,6 @@
  const goBack = () => {
    uni.navigateBack();
  };
  const parsedOrderRow = ref({});
  // 提交表单
  const submitForm = async () => {
    submitting.value = true;
@@ -121,7 +118,7 @@
      return;
    }
    addProductMain(reportForm).then(res => {
    addProductMain(form.value).then(res => {
      if (res.code === 200) {
        showToast("报工成功");
        submitting.value = false;
@@ -134,22 +131,17 @@
  };
  // 页面加载时初始化数据
  onMounted(() => {
    // 获取传递过来的orderRow参数
    const pages = getCurrentPages();
    const currentPage = pages[pages.length - 1];
    const orderRow = currentPage.options.orderRow;
    form.value.remainingQuantity = 1;
    if (orderRow) {
      parsedOrderRow.value = JSON.parse(orderRow);
  onLoad(options => {
    console.log(options, "options");
    const orderRow = JSON.parse(options.orderRow);
    console.log(orderRow, "orderRow======########");
      form.value.quantity = parsedOrderRow.value.quantity;
      form.value.productProcessRouteItemId =
        parsedOrderRow.value.productProcessRouteItemId;
      form.value.workOrderId = parsedOrderRow.value.id;
      form.value.reportWork = parsedOrderRow.value.reportWork;
      form.value.productMainId = parsedOrderRow.value.productMainId;
    }
    form.value.remainingQuantity = 1;
    form.value.quantity = orderRow.quantity;
    form.value.productProcessRouteItemId = orderRow.productProcessRouteItemId;
    form.value.workOrderId = orderRow.id;
    form.value.reportWork = orderRow.reportWork;
    form.value.productMainId = orderRow.productMainId;
    getInfo().then(res => {
      form.value.userId = res.user.userId;
      form.value.userName = res.user.userName;