2 天以前 46624ce480a3c14da21f39cc4ad5f7eecea2bb1e
src/views/basicData/mdm/data.ts
@@ -9,7 +9,6 @@
import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { MesAutoCodeRuleCode } from '@vben/constants';
import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
import { getUnitPage } from '#/api/mdm/unit';
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
@@ -22,24 +21,6 @@
// 缓存仓库列表
let warehouseListCache: any[] | null = null;
let warehouseListPromise: Promise<any[]> | null = null;
/** 将扁平分类列表转为 TreeSelect 所需的树形结构 */
export function buildCategoryTree(list: any[]): any[] {
  const map = new Map<number, any>();
  const roots: any[] = [];
  for (const item of list) {
    map.set(item.id, { label: item.name, value: item.id, children: [] });
  }
  for (const item of list) {
    const node = map.get(item.id)!;
    if (item.parentId && map.has(item.parentId)) {
      map.get(item.parentId)!.children.push(node);
    } else {
      roots.push(node);
    }
  }
  return roots;
}
/** 获取单位列表(带缓存) */
async function getUnitListCached() {
@@ -82,7 +63,7 @@
}
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi, categoryTreeData: any[] = []): VbenFormSchema[] {
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
  return [
    {
      component: "Input",
@@ -124,19 +105,6 @@
        placeholder: "请输入品种名称",
      },
      rules: "required",
    },
    {
      component: "TreeSelect",
      fieldName: "categoryId",
      label: "品种分类",
      rules: "selectRequired",
      componentProps: {
        placeholder: "请选择品种分类",
        allowClear: true,
        treeDefaultExpandAll: true,
        treeData: categoryTreeData,
        fieldNames: { label: 'label', value: 'value', children: 'children' },
      },
    },
    {
      component: "Input",
@@ -242,17 +210,6 @@
      label: "条码",
      componentProps: {
        placeholder: "请输入条码",
      },
    },
    {
      component: "InputNumber",
      fieldName: "purchasePrice",
      label: "采购价",
      componentProps: {
        class: "!w-full",
        min: 0,
        precision: 2,
        placeholder: "请输入采购价",
      },
    },
    {
@@ -541,12 +498,6 @@
      minWidth: 150,
    },
    {
      field: "categoryName",
      title: "品种分类",
      minWidth: 120,
      slots: { default: "categoryName" },
    },
    {
      field: "unitMeasureName",
      title: "单位",
      minWidth: 80,
@@ -575,14 +526,6 @@
      field: "warehouseName",
      title: "默认仓库",
      minWidth: 100,
    },
    {
      field: "purchasePrice",
      title: "采购价",
      minWidth: 100,
      formatter: ({ cellValue }) => {
        return cellValue != null ? `¥${Number(cellValue).toFixed(2)}` : "";
      },
    },
    {
      field: "salesPrice",