spring
9 小时以前 485b7ada4dfb24f77e2ac5ed871bf23b07f086ad
src/views/salesManagement/salesLedger/index.vue
@@ -718,7 +718,9 @@
const getProductOptions = () => {
  // 返回 Promise,便于在编辑产品时等待加载完成
  return productTreeList().then((res) => {
    productOptions.value = convertIdToValue(res);
    // 兼容接口返回 { data: [] } 或直接返回数组
    const list = Array.isArray(res) ? res : (res?.data ?? []);
    productOptions.value = convertIdToValue(list);
    return productOptions.value;
  });
};
@@ -757,6 +759,7 @@
  return null; // 没有找到节点,返回null
};
function convertIdToValue(data) {
  if (!data || !Array.isArray(data)) return [];
  return data.map((item) => {
    const { id, children, ...rest } = item;
    const newItem = {
@@ -1020,6 +1023,12 @@
  productOperationType.value = type;
  productForm.value = {};
  proxy.resetForm("productFormRef");
  // 新增、编辑都需先加载产品树,否则 el-tree-select 无数据
  try {
    await getProductOptions();
  } catch (e) {
    console.error("加载产品树失败", e);
  }
  if (type === "edit") {
    productForm.value = { ...row };
    productIndex.value = index;