| | |
| | | import { createItem, getItem, updateItem } from '#/api/mdm/item'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useFormSchema } from '../data'; |
| | | import { useFormSchema, clearUnitListCache, buildCategoryTree } from '../data'; |
| | | import { getItemTypeSimpleList } from '#/api/mes/md/item/type'; |
| | | |
| | | defineOptions({ name: "ItemForm" }); |
| | | |
| | |
| | | return; |
| | | } |
| | | const data = modalApi.getData<MdmItemApi.Item>(); |
| | | // 清除单位缓存,确保获取最新数据 |
| | | clearUnitListCache(); |
| | | // 加载最新分类数据 |
| | | const categoryRes = await getItemTypeSimpleList(); |
| | | const categoryTreeData = buildCategoryTree(categoryRes || []); |
| | | // 设置 schema(formApi 已初始化) |
| | | formApi.setState({ schema: useFormSchema(formApi) }); |
| | | formApi.setState({ schema: useFormSchema(formApi, categoryTreeData) }); |
| | | if (data?.id) { |
| | | // 编辑模式 |
| | | modalApi.lock(); |