于杰
45 分钟以前 69a25cd577d5639f2869bcf80f498b373e80137e
north-glass-erp/northglass-erp/src/views/pp/processCard/AddProcessCard.vue
@@ -265,7 +265,7 @@
    },
    {
      field: 'building_number',
      field: 'buildingNumber',
      title: t('order.buildingNumber'),
      sortable: true,
      filters: [{data: ''}],
@@ -343,6 +343,7 @@
    form.productionId = productionId
    request.post(`/processCard/processCardAutoRack`,form).then(res => {
      xGridLeft.value.reloadData(res.data.orderDetailList)
      console.log(res.data.orderDetailList)
      xGrid.value.reloadData(res.data.orderDetailsNotScope)
    })
  },
@@ -738,13 +739,13 @@
    const leftDataList = $gridLeft.getTableData().fullData
    const baseProcessId = productionId // 固定前缀
    // 工具:取ID末尾数字(没有数字则返回极大值,防止相减 NaN/错序)
    // 取ID末尾数字(没有数字则返回极大值,防止相减 NaN/错序)
    const tailNum = (id) => {
      const m = String(id ?? '').match(/(\d+)$/)
      return m ? parseInt(m[1], 10) : Number.MAX_SAFE_INTEGER
    }
    // 1) 先按原 processId 分组
    // 先按原 processId 分组
    const groupedByOld = leftDataList.reduce((acc, row) => {
      const pid = row.processId
      if (!acc[pid]) acc[pid] = []
@@ -752,7 +753,7 @@
      return acc
    }, {})
    // 2) 拿到去重后的旧 processId 列表,并按“末尾数字”正序(小到大)排列
    // 拿到去重后的旧 processId 列表,并按“末尾数字”正序(小到大)排列
    const oldIds = Object.keys(groupedByOld).sort((a, b) => {
      const da = tailNum(a)
      const db = tailNum(b)
@@ -761,14 +762,14 @@
      return String(a).localeCompare(String(b))
    })
    // 3) 构建从旧 processId -> 新 processId 的映射:001, 002, ... 正序递增
    // 构建从旧 processId -> 新 processId 的映射:001, 002, ... 正序递增
    const pidMap = new Map()
    oldIds.forEach((oldId, idx) => {
      const newPid = `${baseProcessId}${String(idx + 1).padStart(3, '0')}`
      pidMap.set(oldId, newPid)
    })
    // 4) 应用映射,并设置 landingSequence:同组同序号,且从 1 开始递增
    oldIds.forEach((oldId, idx) => {
      const group = groupedByOld[oldId]
      const newPid = pidMap.get(oldId)
@@ -1006,7 +1007,7 @@
          //   (plain.computeGrossArea || 0) - (plain.width * plain.height * qtyToMove) / 1000000
          // ).toFixed(2)
        }
        $gridLeft.insertAt(newRow, -1) // ✅ 永远插到表尾
        $gridLeft.insertAt(newRow, -1) //  永远插到表尾
      }
    }
@@ -1202,18 +1203,14 @@
    if ($grid) {
      switch (code) {
        case 'saveFlowCard': {
          gridLeftOptions.toolbarConfig.buttons[0].disabled=true
          const $table = xGridLeft.value
          const $tableRight = xGrid.value
          if ($table) {
            const selectRecords = $table.getCheckboxRecords()
            //  const selectRight = $tableRight.getCheckboxRecords()
            let leftData = $tableRight.getTableData().fullData
            // if (selectRecords.length === 0) {
            //   ElMessage.warning(t('processCard.pleaseSelectTheSavedDataFirst'))
            //   gridLeftOptions.toolbarConfig.buttons[0].disabled=false
            //   return
            // }
            let data = $table.getTableData().fullData
            if (leftData.length > 0) {
              ElMessage.warning(t('processCard.pleaseFirstCreateAProcessCardForAllTheDataOnTheRightSideAndSaveIt'))
@@ -1229,11 +1226,8 @@
              gridLeftOptions.toolbarConfig.buttons[0].disabled = false;
              return;
            }
            // if (leftData.length!=selectRecords.length){
            //   ElMessage.warning('请勾选所有数据进行保存')
            //   gridLeftOptions.toolbarConfig.buttons[0].disabled=false
            //   return;
            // }
            gridOptions.loading=true
            gridLeftOptions.loading=true
            let flowCardData = ref({
              flowCard: data,
              userName: username,
@@ -1244,14 +1238,15 @@
            request.post(`/processCard/addFlowCard/${orderId}`, flowCardData.value).then((res) => {
              if (res.code == 200) {
                ElMessage.success(t('basicData.msg.saveSuccess'))
                //router.push('/main/processCard/SplittingDetails?orderId=${orderId}')
                router.push({
                  path: '/main/processCard/AddProcessCard',
                  query: {orderId: orderId, productionId: productionId, random: Math.random()}
                })
                //location.reload();
                gridOptions.loading=false
                gridLeftOptions.loading=false
              } else {
                gridOptions.loading=false
                gridLeftOptions.loading=false
                ElMessage.warning(res.msg)
              }
            })