gongchunyi
2026-06-20 4c3dee416ab4940d10e43af0e0ec79433ddd012a
src/views/salesManagement/salesLedger/index.vue
@@ -123,9 +123,11 @@
              </el-table-column>
              <el-table-column label="快递公司"
                               prop="expressCompany"
                               v-if="false"
                               show-overflow-tooltip />
              <el-table-column label="快递单号"
                               prop="expressNumber"
                               v-if="false"
                               show-overflow-tooltip />
              <el-table-column label="发货车牌"
                               minWidth="100px"
@@ -722,17 +724,38 @@
              </el-select>
            </el-form-item>
          </el-col>
<!--          <el-col :span="12">
          <el-col :span="12">
            <el-form-item label="是否生产:"
                          prop="isProduction">
              <el-radio-group v-model="productForm.isProduction">
                <el-radio label="是"
                          :value="true" />
                <el-radio label="否"
                          :value="false" />
              </el-radio-group>
              <div style="display: flex; align-items: center; width: 100%;">
                <el-radio-group v-model="productForm.isProduction">
                  <el-radio label="是"
                            :value="true" />
                  <el-radio label="否"
                            :value="false" />
                </el-radio-group>
                <div
                  v-if="currentStock !== null"
                  :style="{
                    marginLeft: '20px',
                    padding: '0 12px',
                    height: '28px',
                    lineHeight: '28px',
                    borderRadius: '4px',
                    fontSize: '13px',
                    fontWeight: '500',
                    display: 'inline-block',
                    whiteSpace: 'nowrap',
                    backgroundColor: (productForm.quantity || 0) > currentStock ? '#fff0f0' : '#f0f9eb',
                    border: (productForm.quantity || 0) > currentStock ? '1px solid #ffcccc' : '1px solid #e1f3d8',
                    color: (productForm.quantity || 0) > currentStock ? '#f56c6c' : '#67c23a'
                  }"
                >
                  <span>当前库存:{{ currentStock }} {{ productForm.unit || '' }}</span>
                </div>
              </div>
            </el-form-item>
          </el-col>-->
          </el-col>
        </el-row>
      </el-form>
    </FormDialog>
@@ -917,6 +940,7 @@
                <el-option label="货车"
                           value="货车" />
                <el-option label="快递"
                           v-if="false"
                           value="快递" />
              </el-select>
            </el-form-item>
@@ -939,7 +963,7 @@
            </el-form-item>
          </el-col>
          <el-col :span="24"
                  v-else>
                  v-else-if="false">
            <el-form-item label="快递公司:"
                          prop="expressCompany">
              <el-input v-model="deliveryForm.expressCompany"
@@ -949,7 +973,7 @@
          </el-col>
        </el-row>
        <el-row :gutter="30"
                v-if="deliveryForm.type === '快递'">
                v-if="false">
          <el-col :span="24">
            <el-form-item label="快递单号:"
                          prop="expressNumber">
@@ -1017,6 +1041,7 @@
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary"
                     :loading="deliveryLoading"
                     @click="submitDelivery">确认发货
          </el-button>
          <el-button @click="closeDeliveryDia">取消</el-button>
@@ -1182,6 +1207,7 @@
  // 发货相关
  const deliveryFormVisible = ref(false);
  const deliveryLoading = ref(false);
  const currentDeliveryRow = ref(null);
  const getDeliveryBatchQuantity = item => {
    const quantity =
@@ -1192,6 +1218,27 @@
      item?.qualifiedQuantity ??
      item?.stockQuantity;
    return quantity ?? 0;
  };
  const currentStock = ref(null);
  const fetchCurrentStock = async (productModelId) => {
    if (!productModelId) {
      currentStock.value = null;
      return;
    }
    try {
      const res = await getStockInventoryByModelId(productModelId);
      const rawList = Array.isArray(res?.data)
        ? res.data
        : res?.data?.records || res?.data?.rows || [];
      let total = 0;
      rawList.forEach(item => {
        total += Number(getDeliveryBatchQuantity(item) || 0);
      });
      currentStock.value = total;
    } catch (e) {
      console.error(e);
      currentStock.value = 0;
    }
  };
  const getCurrentDeliveryRowQuantity = () => {
    return Number(currentDeliveryRow.value?.noQuantity || 0);
@@ -1458,6 +1505,7 @@
  // 获取tree子数据
  const getModels = value => {
    productForm.value.productCategory = findNodeById(productOptions.value, value);
    currentStock.value = null;
    modelList({ id: value }).then(res => {
      modelOptions.value = res;
    });
@@ -1467,9 +1515,11 @@
    if (index !== -1) {
      productForm.value.specificationModel = modelOptions.value[index].model;
      productForm.value.unit = modelOptions.value[index].unit;
      fetchCurrentStock(value);
    } else {
      productForm.value.specificationModel = null;
      productForm.value.unit = null;
      currentStock.value = null;
    }
  };
  const findNodeById = (nodes, productId) => {
@@ -1738,7 +1788,7 @@
        taxInclusiveTotalPrice: taxInclusiveTotalPrice,
        taxExclusiveTotalPrice: taxExclusiveTotalPrice,
        invoiceType: "增普票",
        isProduction: true,
        isProduction: false,
        productId: p.productId,
        productModelId: p.productModelId,
      };
@@ -1793,8 +1843,9 @@
    productOperationType.value = type;
    productForm.value = {};
    currentStock.value = null;
    if (type === "add") {
      productForm.value.isProduction = true;
      productForm.value.isProduction = false;
    }
    proxy.resetForm("productFormRef");
    if (type === "edit") {
@@ -1819,6 +1870,7 @@
          );
          if (currentModel) {
            productForm.value.productModelId = currentModel.id;
            fetchCurrentStock(currentModel.id);
          }
        }
      } catch (e) {
@@ -2760,6 +2812,7 @@
        const productModelId =
          currentDeliveryRow.value.productModelId ||
          currentDeliveryRow.value.modelId;
        deliveryLoading.value = true;
        addShippingInfo({
          salesLedgerId: salesLedgerId,
          salesLedgerProductId: currentDeliveryRow.value.id,
@@ -2810,6 +2863,8 @@
              });
            }
          });
        }).finally(() => {
            deliveryLoading.value = false;
        });
      }
    });