spring
2026-04-02 61449dbf92441b41e37c1d519e8662cca998ff6a
src/views/procurementManagement/procurementLedger/index.vue
@@ -88,6 +88,8 @@
                               prop="specificationModel" />
              <el-table-column label="单位"
                               prop="unit" />
              <el-table-column label="料号"
                               prop="materialCode" />
              <el-table-column label="数量"
                               prop="quantity" />
              <el-table-column label="税率(%)"
@@ -405,6 +407,8 @@
                           prop="productCategory" />
          <el-table-column label="规格型号"
                           prop="specificationModel" />
          <el-table-column label="料号"
                           prop="materialCode" />
          <el-table-column label="单位"
                           prop="unit"
                           width="70" />
@@ -565,6 +569,23 @@
                           :label="item.model"
                           :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="料号:"
                          prop="materialCode">
              <el-input v-model="productForm.materialCode"
                        placeholder="请输入"
                        disabled />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="批号:"
                          prop="batchNo">
              <el-input v-model="productForm.batchNo"
                        clearable
                        placeholder="选填,可输入批号;留空将自动生成" />
            </el-form-item>
          </el-col>
        </el-row>
@@ -952,6 +973,8 @@
      productCategory: "",
      productModelId: "",
      specificationModel: "",
      materialCode: "",
      batchNo: "",
      unit: "",
      quantity: "",
      taxInclusiveUnitPrice: "",
@@ -1587,9 +1610,11 @@
    if (index !== -1) {
      productForm.value.specificationModel = modelOptions.value[index].model;
      productForm.value.unit = modelOptions.value[index].unit;
      productForm.value.materialCode = modelOptions.value[index].materialCode;
    } else {
      productForm.value.specificationModel = null;
      productForm.value.unit = null;
      productForm.value.materialCode = null;
    }
  };
  const findNodeById = (nodes, productId) => {
@@ -1620,10 +1645,28 @@
      return newItem;
    });
  }
  /** 与库存新增一致:未填批号时前端生成(PH + 时间戳 + 随机数) */
  const generateProductBatchNo = () => {
    const d = new Date();
    const pad = (n) => String(n).padStart(2, "0");
    const ts = `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
    const r = Math.floor(Math.random() * 10000)
      .toString()
      .padStart(4, "0");
    return `PH${ts}${r}`;
  };
  const ensureProductBatchNo = () => {
    const v = (productForm.value.batchNo ?? "").toString().trim();
    productForm.value.batchNo = v || generateProductBatchNo();
  };
  // 提交产品表单
  const submitProduct = () => {
    proxy.$refs["productFormRef"].validate(valid => {
      if (valid) {
        ensureProductBatchNo();
        if (operationType.value === "edit") {
          submitProductEdit();
        } else {